Comments (2)
Fact is, the CacheService doesn't invalidate the outdated keys by its own, that is right. The documentation should be more clear here that you should implement your "garbage collector" on your own like that.
window.setInterval(() => {
this._cacheService.invalidate(this._cacheService.outdatedKeys);
}, 10000);
- What we actually want to cache is values, not keys. We should TTL the values, not the keys. Only when the key is written to should TTL start counting down for it.
I dont know what you mean. This is a key-value-store where you only can TTL the key.
- When a key times out before the value is written, discard the write (and emit a warning, I guess): This cache is not properly configured to handle the response times encountered, so they will never be cached.
A write always refreshes the key TTL.
There is only one real issue for a race condition, when the loading callback takes too long.
this._cacheContainer[key] = [
now,
loadingFunction().then(object=>{
return this._cacheContainer[key][1] = Promise.resolve(object);
})
];
when the loadingFunction()
takes more than the cacheTtlSeconds
, the key could be deleted in the meantime and this._cacheContainer[key]
became undefined. In this case, the better option should be to write:
this._cacheContainer[key] = [
now,
loadingFunction().then(object=>{
const now = (Date.now()/1000);
return this._cacheContainer[key] = [now, Promise.resolve(object)];
})
];
That should fix it.
Opinions?
We should have tests for that.
from aurelia-components.
Mmh. Maybe I should demonstrate... created #42 .
... If the TTL is lower than the time to answer, then TTL-ing the key will result in never receiving it. So I figure, maybe we'd better TTL the value.
from aurelia-components.
Related Issues (16)
- Invalid Release 1.0.17 HOT 3
- Please review PRs HOT 3
- Replace momentjs HOT 2
- Decide on renovate bot HOT 1
- Bootstrap 5 popover support HOT 1
- Dependency Dashboard
- Strengthen TypeScript transpiler options HOT 1
- optionalPeerDependencies do not exist HOT 1
- Zombie key may replace living key in CacheService
- Use IntersectionObserver for BecomeVisibleCustomAttribute
- Transition to SemVer HOT 1
- Upcoming contributor changes HOT 1
- [Enhancement] Enable sorting by boolean in SortValueConverter
- Name of PopoverCustomAttribute clashes with upcoming native HTML popover attribute
- Is this library still maintained? HOT 1
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 aurelia-components.