rfink / sequelize-redis-cache

Small fluent interface for caching sequelize database query results in redis more easily
MIT License
174 stars 47 forks source link

Include model is not executing query from cache #15

Closed sohaibfarooqi closed 8 years ago

sohaibfarooqi commented 8 years ago

Hi, I tried following query:

var cacheObj = models.cacher('type').ttl(5000);
return cacheObj.findAll
                  (
                       {
                          include   : [{model: models.type_lang , attributes: ['type_title_l1',                      
                                                      'type_alternate_title_l1']}],
                           attributes: ['type_id' , 'type_title' , 'type_htaccess' , 'p' , 'type_alternate_title']
                        }
                   ).then(function(all_types) {
                                          console.log(cacheObj.cacheHit); // true or false
                                          return all_types;
                                   });

But everytime it shows false on console.log(cacheObj.cacheHit). What have i missed?

rfink commented 8 years ago

Hello and thanks for trying out my module,

Can you turn this into a plunker or jsfiddle? I'd be happy to take a look.

NotJustClarkKent commented 8 years ago

I am having the same issue, taking away the includes: property from find (findOne/findAll) and the object is returned from the cache.

rfink commented 8 years ago

Thanks for the fix! I've published as version 1.2.0, along with dependency updates so this module can be tested with node 4.x, 5.x, and 6.x.

NotJustClarkKent commented 8 years ago

Glad I could help, thanks for your work and the quick turnaround on that PR! 💯