GithubHelp home page GithubHelp logo

Comments (4)

whitfin avatar whitfin commented on July 2, 2024 1

More thoughts on LRU:

  • We can provide a touch function which is basically refresh without updating the TTL (so it just updates the write time).
  • An LRU policy can simply invoke the LRW policy, but add in a hook which touches keys when they're read.
  • If you don't want all keys to be read, maybe we add a touch: false option to all read operations?
  • Alternatively, you can just use an LRW policy and touch keys when you wish.

This would mean that we only have one heavy lifting policy (LRW), but support both the LRW and LRU use cases. I think this is elegant, and should suffice for now - things like LFU would be extremely difficult to implement without introducing higher memory usage.

from cachex.

whitfin avatar whitfin commented on July 2, 2024

Currently I have an implementation of an LRW (least-recently written) hook which works and caps based on a given reclaiming boundary. This is implemented entirely without need for separate storage and is actually quite cheap, and seems to be pretty fast (as much as you can expect, anyway).

Not entirely sure about how to create an LRU which doesn't need some sort of key tracking, which would naturally make it way more expensive (because there would be a write on every read). It may just be that we go with just LRW for 2.x and direct people to touch their keys as needed.

from cachex.

whitfin avatar whitfin commented on July 2, 2024

LRW is merged in. LRU is going to take a little time because there are a few other issues to cleanup first before I take a shot at that (because I'd just have to rewrite it).

@emerleite feel free to play around with Master to try out the limits.

from cachex.

emerleite avatar emerleite commented on July 2, 2024

@zackehh thanks. I'll start using this next week ;)

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.