-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Short-term memory #103
Short-term memory #103
Conversation
Interesting point @wfrank2509 - I'm going to wait until after the pending minor release to merge this. I'm also adding user-defined cache stages to to the feature list for the upcoming v1.0.0, inspired by this. Definitely makes sense to leverage the power of ST memory in front of the persistence of a LT redis store. Also, thanks for the clean PR, docs update, etc! 👍 |
Fair warning, there are some merge conflicts you'll need to fix once the merge takes place... you can jump start the process by merging in #97 and fixing locally... |
Ok, thanks. |
Just check against master now @wfrank2509 - v0.9.0 is out of the gate! |
The redis related tests don't seem to run in travis CI. The getting redis cache hits code is not executed. Can you help here? |
@wfrank2509 - mind getting the merge conflicts resolved and test coverage implemented? This is a feature I'm considering for v1.x |
@kwhitley Not sure how I can activate the redis tests for travis-ci and coveralls? It looks like the missing coverage is caused by the redis tests not running? How do you test the redis scenarios? With a mock for RedisClient? The coverage report shows the whole code path with the reds config is not executed. Somehow the 'var redis = require('fakeredis')' setting for mockAPI in the test does not set redis ? |
@wfrank2509 There's a fake redis server for use in the tests as you've found. According to the TravisCI report, your code hasn't broken any of the existing tests, so now it's a case of covering the new code. I'll download your PR today and take a look, time willing! (I need to clean up some of the options tests in the main branch anyway) |
Ahhh... you must have forked from a point before we fixed the restify branch - I notice 2 of the 4 environment emulations are commented out, showing a max of 84 tests (we are currently at around 136) run. |
Also, instead of implementing your own shortTerm cache Set, why not use the built-in memCache object (see memory-cache.js for API) for your short term cache? It handles things like timeouts, self-clearing, etc. If using redis, it would otherwise be ignored, but it's sitting there in the apicache instance... so may as well use that rather than add more code. Either way, I'm planning on doing exactly that in v1.x based on your suggestion - use the internal memory cache as a short term buffer when using redis to alleviate the pressure (and speed up the responses). I love your concept, and seeing the slow speed of redis requests compared to the <1ms responses from the memory cache, it should definitely improve production environments. 👍 |
Makes total sense! I would have done it that way but didn’t know the code good enough ;) |
We experienced a high load on the redis cache overloading the sockets for redis. As we have very highly frequented data a short-term cache that prevents every cache hit to go to redis helped a lot to get the load from the network.
The caching time for short term should of course be very moderate and shorter than the 'general' set caching time.