Giter Club home page Giter Club logo

Comments (4)

isaacs avatar isaacs commented on August 23, 2024

Idk, kinda sounds like a footgun. If you want an item that doesn't have a TTL, better off using a Map or plain old object instead of a cache that keeps things sorted by expiration.

More to the point, it would require a different data structure internally to do that. This module is able to efficiently prune by taking advantage of the fact that V8 keeps numeric object keys sorted. If a value's TTL is Infinity, then its expiration is also Infinity, which would be cast to the string 'Infinity', and then it'd need a bunch of special case logic to detect non-numeric expiration values. Not really a fit, sorry.

from ttlcache.

isaacs avatar isaacs commented on August 23, 2024

Actually this might not be so bad. It does reduce performance a bit to have the string 'Infinity' in the TTL object, which I'm guessing is owing to it no longer being an object with strictly numeric keys. But it does the right thing without much added complexity. Adding the footgun!

from ttlcache.

isaacs avatar isaacs commented on August 23, 2024

Actually I can do it without having 'Infinity' in the ttl object, it's faster to have the extra check and not take the deopt.

from ttlcache.

marcopeg avatar marcopeg commented on August 23, 2024

from ttlcache.

Related Issues (18)

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.