jaredwray/cacheable

1.2 issue with multiCache wrap

Closed this issue · 4 comments

Sorry this report is extremely light on details since I'm traveling. We use cache-manager with redis cache manager and use multiCache with wrap. When upgrading from 1.1 to 1.2, our wrap function seems to return empty results without calling the source function that generates the result. The only major difference I see in the code is stuff related to isCachableValue.. This may be a bug with the redis cache manager, but just wanted to post something here in case it gives a hint to something that may need fixing. Thanks for the awesome project! We use it a lot.

Thanks @amit777 -- I'll check it out.

It might be related to this:
dial-once/node-cache-manager-redis@e008a25

Maybe the isCachableValue() is missing an underscore at the beginning of the function name?

So, at least for now, one fix is to specify an isCacheableValue function in the options param when you set up your multiCaching object. E.g.,

var multiCache = cacheManager.multiCaching(
    [redisCache, redisCache2],
    {
        isCacheableValue: function(value) {
            return value !== null && value !== undefined;
        }
    }
);

The other, easier fix is to include node-cache-manager version 1.1.0 in your package.json, which should force node-cache-manager-redis to use that version.

In the meantime I'll try to figure out a real fix. It might be that I should revert the changes for 1.2.0, but not sure yet.

Indeed, the problem was related to the multiCaching. The isCacheableValue function of the underlying cache was never called.

Thanks !