generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is function(id, next) where:
id - the id string or object provided to the get() method.
next - the method called when the new item is returned with the signature function(err, value, ttl) where:
err - an error condition.
value - the new value generated.
ttl - the cache ttl value in milliseconds. Set to 0 to skip storing in the cache. Defaults to the cache global policy.
When using the in-memory driver the next() function act as you would expect
CALLED FOR: getRecentGames ********
getRecentGames generating
getRecentGames doesnt want to cache
CALLED FOR: getMatch ********
getMatch generating
getMatch doesnt want to cache
When I switch to the redis driver the same code does the following:
CALLED FOR: getRecentGames ********
getRecentGames generating
getRecentGames doesnt want to cache
CALLED FOR: getMatch ********
getMatch generating
getRecentGames from CACHE
getRecentGames doesnt want to cache
getMatch doesnt want to cache
The code itself calls "getRecentGames" and then it calls "getMatch", I then after some calculations invoke the next() function like that:
next(null, cached_val, 0);
because I dont want to cache the value (after a check the code decided it doesnt need to cache it).
But it seems like when using the redis driver the next() function does totally different things and is calling twice parts of my code.
The code itself is pretty complicated so I can't post it here but how come switching drivers cause the next() function behave so different?
I wanted to debug it but I can't seem to understand catbox code:
Where is the code that is responsible for creating the next() function?
Where can I find the implementation of the next() function for each driver?
When following the code on the repos it was hard to follow all the callbacks so I got lost in tracking how things flow from generateFunc up to next()
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
From the docs:
When using the in-memory driver the next() function act as you would expect
When I switch to the redis driver the same code does the following:
The code itself calls "getRecentGames" and then it calls "getMatch", I then after some calculations invoke the next() function like that:
next(null, cached_val, 0);
because I dont want to cache the value (after a check the code decided it doesnt need to cache it). But it seems like when using the redis driver the next() function does totally different things and is calling twice parts of my code.The code itself is pretty complicated so I can't post it here but how come switching drivers cause the next() function behave so different? I wanted to debug it but I can't seem to understand catbox code:
When following the code on the repos it was hard to follow all the callbacks so I got lost in tracking how things flow from generateFunc up to next()