rfink/sequelize-redis-cache

Can't call instance method after caching

Closed this issue · 4 comments

wong2 commented

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

rfink commented

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

wong2 commented

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

wong2 commented

Perhaps with Model.build?

rfink commented

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.