Coder Social home page Coder Social logo

Comments (4)

angelnikolov avatar angelnikolov commented on June 25, 2024

@stnor Thanks for the feedback!
So what you are suggesting is basically, keeping the cache for a parameter forever?
Then, the only way to evict the cache would be the user to use a cacheBuster and evict it manually, which makes the cache layer a bit more imperative.
Can you provide me with an example use case where you would need a global maxCacheCount? We can add that easily, in fact I thought of making the whole cacheConfig available as a global setting, since now we can only provide small portion of the config settings to the whole application.

Also #56 points out that we need a selective cache eviction. Like, you could want to only evict certain values from the cache, when you call a cache buster or the global one, while with the maxCacheCount you don't care about specific cached values, you just want to remove the least recent one.
We can of course add an option like keepAlive (or another term if you prefer) which will basically tell the decorators to keep the cache no matter what, unless it's evicted manually. How does that sound?
I wouldn't want to introduce it as a default behaviour because that will be a large breaking change.

from ts-cacheable.

stnor avatar stnor commented on June 25, 2024

I was thinking that as a user I would like to register defaults with a static method, so that if I want a certain TTL or maxCacheCount by default, I could decide so for myself, keeping things DRY.

from ts-cacheable.

angelnikolov avatar angelnikolov commented on June 25, 2024

@stnor Yes, this is what I meant by the global config.
It will be something like what we have now for global storage strategy, or:

GlobalCacheConfig.storageStrategy = DOMStorageStrategy;

To evolve that I am thinking of introducing all options of the cache config globally, like maxCacheCount, maxAge and slidingExpiration. Is that something that would help you?
Also, we can introduce a global and local cache config option of keepAlive which will keep all caches indefinitely.

from ts-cacheable.

stnor avatar stnor commented on June 25, 2024

Yes, sounds great!

from ts-cacheable.

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.