Skip to content

Same cache used for query with different where #31

@Naoto-Ida

Description

@Naoto-Ida

I have a setup like this:

var cacher = require('sequelize-redis-cache');
var redis = require('redis');
var Sequelize = require('sequelize');

var rc = redis.createClient(6379, 'localhost');
var db = new Sequelize('cache_tester', 'root', 'root', { dialect: 'mysql' });
var cacheObj = cacher(db, rc)
  .model('sequelize-model-name')
  .ttl(5);
const find1 = await cacheObj.find({attributes:['name'], where: { type: 'user', confirmed: true } })
const find2 = await cacheObj.find({attributes:['name'], where: { type: 'admin', confirmed: true } })

When I log the queries,
SELECT 'name' FROM 'sequelize-model-name' WHERE id = 2 is run twice...
At first I thought the use of async/await seemed to cause the issue,
but changing to then didn't change the fact.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions