Closed marybeshaw closed 9 years ago
One of the solutions you proposed is to provide a public function that tells an implementer whether the cache was successfully initialized. You already have access to this data like so:
if(cache.db){
//Proceed
}
So, whether you're using redisCacheModule
as a standalone cache or instantiating it and then injecting it into a cacheService
instance, just check the .db
property first.
Yes, that will work great! Thanks!
This is an issue I found with my unit tests, where the redis cache isn't used. It doesn't matter if the cache is set up properly, but the behavior is odd when it's not set up properly (which can happen when setting up redis initially).
I am finding that, in the redis cache, if the client isn't created and the function mget() is called, I get a runtime error: TypeError: Object false has no method 'mget'. I've explained the issue below, and suggested a couple of solutions that would make the modules a bit more robust. Do you agree with the proposed solution(s)? Would you like me to implement the fixes?
An example of what can happen:
Possible solutions:
Have a great day! Mary