Closed rbpinheiro closed 7 years ago
DataLoader is a local in-memory cache, sort of like your browser's cache. Redis is a backing store which should be loaded from, see the example in Readme https://github.com/facebook/dataloader#common-back-ends
Here is a implementation that adds a Redis cache layer in place of the in memory cache. https://www.npmjs.com/package/redis-cache-dataloader
I am trying to implement a cacheMap that is async. Meaning the the "get" function needs to inform asynchronously wether the specified key is cached or not. But that is not working.
My code is here: https://gist.github.com/rbpinheiro/942218abe33a6b533d37bbd9e70e129c
It seems that returning a promise on "get" is the same as stating a cache hit. If you uncomment line 9, that returns false, it will always assume a cache miss. How to implement the cache miss asynchronously?
I investigated dataloader's code and found this on line 87:
That "if" seems to be the only check for cache miss, which doesn't cover the asynchronous case.