Coder Social home page Coder Social logo

Comments (6)

angelnikolov avatar angelnikolov commented on June 25, 2024

Yes, you can use

@Cacheable({
    maxCacheCount: 40
})

. Let me know if that works for ya!

from ts-cacheable.

jmls avatar jmls commented on June 25, 2024

the 40 items are an array from a api call. I now have a new item that I want to insert into this array.

from ts-cacheable.

angelnikolov avatar angelnikolov commented on June 25, 2024

Well can you do it @ the component level. Say you have

this.data = this.service.getCachedData() // this returns the initial forty items
socket.on('event', data=> this.data.push(data))

?
If you want to update the cache to contain 41 items afterwards, I don't think this is possible right now, since the cache is not exposed out of the decorator and it's accessed by it via closure.

from ts-cacheable.

jmls avatar jmls commented on June 25, 2024

yeah, I was trying to keep it at the store level - I thought that this may be the case. At the component level won't work because the next component that makes the same api request will get the old 40 items, unless I bust the cache and re-read (Which seems a shame as I have to re-read 41 items, where I already have the 40 in memory)

Thanks

from ts-cacheable.

angelnikolov avatar angelnikolov commented on June 25, 2024

Yeah I remember that I was thinking about a third decorator called @CacheUpdater, which will basically work the same way as the @CacheBuster (i.e share a notifier subject) but only work one-way and be used to update the cache of the @Cacheable but didn't have time for it. If you got time and want to do it, go ahead, I think it will be a nice addition! :))

from ts-cacheable.

angelnikolov avatar angelnikolov commented on June 25, 2024

Closing due to inactivity.

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.