Comments (5)
@ilaif it's unfortunately not easy to address with current internal design, which doesn't really allow to refresh the value without invaliding the cache upfront, and at same time make this operation not problematic and transparent to any eventual extensions to which internals try to remain agnostic.
I plan to refactor the internals so handling cache that way is possible and straightforward (should happen in Q1 of next year). otherwise, trying to implement some workaround on existing implementation, while probably possible, for sure is challenging and may rise few head-aches. Anyway I'm open for PR's :)
from memoizee.
Current prefetch implementation drops cache value immediately after start.
I don't think it works that way. To me prefetch
works exactly you want it to work. Can you prepare a simple test case which shows it's otherwise (?)
from memoizee.
Probably me & @Kirill89 did not understood right what happens. Could you explain this 2 lines https://github.com/medikoo/memoizee/blob/v0.3.9/ext/max-age.js#L49-L50 ?
It looks like when prefetch starts, it immedeately drops cache data with conf.delete(...)
.
from memoizee.
This is called after value being accessed, and !preFetchTimeouts[id]
means that prefetchAge time has passed and value should be prefetched for next access.
To prefetch value we call again memoized function, however this can't work properly without previously deleting cached value (if we won't delete it, memoized function will returned cache value).
It's indeed as I look now, not ideal, as when we ask for a result when new value is being retrieved, then instead of returning old value, result will be postponed until refreshed value arrives.
So it's as you say, sorry first I misunderstood I thought you say in general values are dropped right after being memoized.
Right fix for that would be, to not call memoized function but underlying function, and replace result after having it. This unfortunately is not that straightforward with various extensions (like e.g. resolvers), or different method of obtaining results (e.g. async, promise), Still should be addressed.
from memoizee.
Hey Medikoo,
Thanks for this awesome work. I'm using your package successfully and it has great performance.
I encountered the need for the enhancement stated here.
Is there a roadmap for it, can I contribute in some way?
My use-case:
I have dozens of requests per second. Each of them passes through authentication against a MySQL table. Since I have 1 db instance, then sometimes, during big loads I get long query times (> 10 seconds) for these trivial queries (Usually under 50 ms). Still, I don't want the client side to be affected, in such a case, I would want to define a "timeout" for fetching the data, that when expires, will return the old cache value and will continue fetching in the background, updating the value for subsequent requests.
from memoizee.
Related Issues (20)
- Promise rejections not cleared immediately from cache HOT 2
- Callback for cache access HOT 5
- setter method HOT 1
- How to deal with functions taking dict args? HOT 6
- Rollup fails to bundle memoizee correctly HOT 6
- feat: let default nomalizer be more general HOT 1
- replace `es5-ext` with `core-js@^3` HOT 2
- Cannot import memoizee HOT 3
- Memoizing a function without arguments HOT 1
- Allow `maxAgeSinceAccess` in addition to `maxAge` HOT 11
- Why is the memoizee so slow? HOT 2
- Is there a way to dynamically configure the size? HOT 7
- Feature Request: Wouldn't it be good if we could use a Redis backend? HOT 2
- max option does not work with promise option HOT 1
- Option to return prior cached value on update failure HOT 5
- Package is showing a vulnerability HOT 7
- [email protected] is broken due to node requirement HOT 10
- typo in engines.node HOT 20
- Found a mistake here that breaks our Pipeline HOT 2
- Codecov badge HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memoizee.