Giter Site home page Giter Site logo

Comments (2)

muesli avatar muesli commented on September 24, 2024

Can you elaborate a bit more what you're suggesting?

from cache2go.

icaiyu avatar icaiyu commented on September 24, 2024

Every expirationCheck will iterate all items including the permanent items and and non-permanent items. I think it unnecessary to check the permanent items, why not store them to another map so that the expirationCheck checks the non-permanent items only.

Plus..
I think that using cleanupInterval to check the expiration is not that efficient.
Like this example:
Add an item with lifespan = 10 to a blank table, the cleanupInterval will be 10s,
6s later, add another item with lifespan = 8, it will call the table.expirationcheck()
because item.lifespan < cleanupInteval
in fact, it's unnecessary to check because 10 - 6 < 8 (the cleanupTimer countdown to 10-6 = 4) .
In a nutshell, the cleanupTimer is really close to call expirationCheck as time goes by, however, the cleanupInterval remains unchanged!

Since we couldn't get the countdown time of the cleanupTimer directly, note down the cleaning time as cleanupTime is helpful to make it.

I submit a PR. If I was wrong please correct me and I will be really grateful. Thank you in advance!

from cache2go.

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.