Closed jmls closed 5 years ago
Yes, you can use
@Cacheable({
maxCacheCount: 40
})
. Let me know if that works for ya!
the 40 items are an array from a api call. I now have a new item that I want to insert into this array.
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.
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
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! :))
Closing due to inactivity.
is it possible to change / emit new values from a cached call ?
Let's say I've loaded 40 items from an http call - and these are being displayed onscreen. Another session adds a new item - which notifies via websockets all interested clients.
How can I take this new item and insert it into the cache so my screen is updated withe the new record, without having to re-read the data from the http call ?