Giter VIP home page Giter VIP logo

Comments (12)

BryanDonovan avatar BryanDonovan commented on July 27, 2024

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.

3choBoomer avatar 3choBoomer commented on July 27, 2024

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.

BryanDonovan avatar BryanDonovan commented on July 27, 2024

Are you using the neverCache function (or equivalent) as your isCacheableValue function?

from node-cache-manager.

3choBoomer avatar 3choBoomer commented on July 27, 2024

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.

BryanDonovan avatar BryanDonovan commented on July 27, 2024

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.

3choBoomer avatar 3choBoomer commented on July 27, 2024

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.

BryanDonovan avatar BryanDonovan commented on July 27, 2024

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.

BryanDonovan avatar BryanDonovan commented on July 27, 2024

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.

3choBoomer avatar 3choBoomer commented on July 27, 2024

Yes, that is what I was suggesting. I'll take a stab at it and update my PR.

from node-cache-manager.

3choBoomer avatar 3choBoomer commented on July 27, 2024

@BryanDonovan finally got around to getting those unit tests in.

from node-cache-manager.

BryanDonovan avatar BryanDonovan commented on July 27, 2024

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.

zzau13 avatar zzau13 commented on July 27, 2024

Fixes by #203

from node-cache-manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.