Comments (12)
Yeah, it's possible that that could be removed. I can't remember why it's there honestly. I doubt it's a big performance hit, especially if redis, etc. is taking a few milliseconds anyway.
from node-cache-manager.
I probably have a special use case that can be found here:
dial-once/node-cache-manager-redis#19
In my testing it effectively doubles the time it takes to get something from the cache, but that's because my multi cache is a cluster of redis machines behind a load balancer, and then the master of that cluster. This way I can write to the master, but read from any of the machines behind the load balancer.
(BTW, thanks for the quick response!)
from node-cache-manager.
Are you using the neverCache
function (or equivalent) as your isCacheableValue
function?
from node-cache-manager.
Yes, I am for the first cache in my multiCache.
My intention is to check the load balancer first, break out of the search for the item, and then write it only to the master node.
I raised a pull request:
#42
from node-cache-manager.
Oh, the reason we use isCacheableValue
in that spot is because if, for example, null
is a cacheable value, and it's found in the first cache, we don't want to keep checking the other caches. Instead, we want to return null
right away.
from node-cache-manager.
That use case makes sense, but if one is caching larger values (like a serialized object) in the cache, wouldn't you want to return that as soon as it's found instead of looking for it again?
The check for null would be really fast, even if it has to look for it in a different cache.
I can see the value of what you're saying, though. Maybe we need another function to determine if the null is a valid value?
from node-cache-manager.
Hmm.. I'm probably not following completely. The intention is that if a value is found, like a large serialized object, it should return it immediately and not look for it in other caches. In that case your isCacheableValue
function could be function(value) { return !!value; }
or something like that.
from node-cache-manager.
OK, I think I see what you're saying now. Not sure how to get around that, other than perhaps having two functions, isCacheableValue
and isReturnableValue
. By default isReturnableValue
could just be set to isCacheableValue
. Not sure if that solves anything though.
from node-cache-manager.
Yes, that is what I was suggesting. I'll take a stab at it and update my PR.
from node-cache-manager.
@BryanDonovan finally got around to getting those unit tests in.
from node-cache-manager.
Sorry @3choBoomer -- I didn't see your comment here. Can you merge the latest from upstream/master and add the same isReturnableValue logic to lib/caching.js as well please? Then I think it's good to go.
from node-cache-manager.
Fixes by #203
from node-cache-manager.
Related Issues (20)
- Under constant load, backend refresh doesn't provide efficient mechanism to save enought backend request HOT 3
- Memory store: how to set the max value to infinite (only allocate memory on new items) HOT 4
- Support hset hget HOT 1
- Optimizing Multicaching Efficiency: Dynamic Data Migration Between Cache Levels HOT 3
- Add the shouldCloneBeforeSet option to the documentation HOT 1
- cache prefix HOT 1
- Cache error fallback (ters) HOT 4
- Why `Promise` object cannot be store correctly? HOT 2
- prefix configuration option for cache keys HOT 3
- Fs cache store engine HOT 1
- Value being set inside "v" field on new version v2 HOT 2
- Map object is not stored HOT 5
- `this.cacheManager.store.client` is undefined HOT 2
- Question: are expired items removed from the in-memory store?
- Bug in docs: "Create single cache store synchronously" doesn't pass options to store HOT 1
- Broken link for 'Example Express App Usage' in README.md HOT 1
- Update TypeScript compilation target years HOT 2
- Receiving error `SyntaxError: Unexpected token 'export'` with v5.6.0 HOT 8
- Malformed cache data HOT 12
- Del with using keyPrefix doesn't work as expected HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-cache-manager.