rfink / sequelize-redis-cache

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

Can't call instance method after caching #25

Closed wong2 closed 8 years ago

wong2 commented 8 years ago

seems the query methods are returning plain js objects instead of model instances? why?

rfink commented 8 years ago

Redis only accepts string or numeric values, so the only data we can cache is plain json.

wong2 commented 8 years ago

@rfink what about build instances with the cached plain json?

wong2 commented 8 years ago

Perhaps with Model.build?

rfink commented 8 years ago

I've actually considered something similar, but the issue goes back to #24, where the module doesn't have a mechanism for invalidating a cached object on insert/update, so the model that is created with Model.build could be out of sync with the database. Model.build could be called by the caller, which would solve this particular issue.