GithubHelp home page GithubHelp logo

Define cache size limit about cachex HOT 13 CLOSED

emerleite avatar emerleite commented on July 21, 2024 1
Define cache size limit

from cachex.

Comments (13)

whitfin avatar whitfin commented on July 21, 2024 1

Coming back to this;

I have a plan to implement this with a hook, but it won't work on a distributed scale (at least I don't think so). I'm going to investigate a way around this in future, perhaps by splitting out the remote caches into their own project.

from cachex.

whitfin avatar whitfin commented on July 21, 2024

@emerleite I've been considering this for a while, but I don't know an efficient way to trim the size, and on what grounds.

The most obvious is LRU, but that requires a sorted table in order to easily determine use time. Any ideas? Perhaps LFU should also be an option... that seems to make the most sense in context.

In the meantime, just set TTLs on your keys - that should be an easy workaround.

from cachex.

whitfin avatar whitfin commented on July 21, 2024

Further thinking on this makes me feel that we can implement LRU with a hook. There will naturally be overhead to this, but it can be toggled on/off if you have a clever enough eviction policy. I just need to work out some of the QLC magic behind it.

from cachex.

emerleite avatar emerleite commented on July 21, 2024

I set the TTL, but with high throughput, I'm not sure if I'll reach the limit anyway.

from cachex.

emerleite avatar emerleite commented on July 21, 2024

@zackehh I guess LFU could be better, but we could have a simple option to just rotate, regardless of the policy.

from cachex.

emerleite avatar emerleite commented on July 21, 2024

I found this project. Do you think we can go through the same aproach? - https://github.com/arago/lru_cache

from cachex.

whitfin avatar whitfin commented on July 21, 2024

@emerleite we can't, because using something like an Agent is a 6x slowdown on all reads against the throughput Cachex has today.

The reason I never added LRU before is simply because it would typically require a write on every read (like that Agent approach). I have an idea, but need to find some time to try an implementation.

from cachex.

emerleite avatar emerleite commented on July 21, 2024

@zackehh makes sense. But how about just set a limit and remove the first inserted? It's just to not reach system limit.

from cachex.

whitfin avatar whitfin commented on July 21, 2024

@emerleite first inserted is possible, but arguably the things you put in a cache instantly and live the longest are also those which need to be cached the most.

from cachex.

whitfin avatar whitfin commented on July 21, 2024

@emerleite how would you imagine this working in the case where you have a distributed cache?

from cachex.

emerleite avatar emerleite commented on July 21, 2024

@zackehh not sure. It's true we have to figure out this.

from cachex.

whitfin avatar whitfin commented on July 21, 2024

@emerleite I opened a new issue in #55. I'm going to close this one but feel free to follow that issue instead.

from cachex.

emerleite avatar emerleite commented on July 21, 2024

Coll @zackehh ;)

from cachex.

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.