wabac
Version:
A versioned cache backed by cloud storage
38 lines (30 loc) • 683 B
Markdown
Initialization
- initialize
- initialize from cli
- reinit
Fetch / update
- fetch latest version
- fetch latest version with max age
- fetch latest version, no later than given date
- delete from cache
- for a page that is gone
- store new version / update version
- update last fetched date if key exists and content is the same
- clean all from cache
Data model notes
- use object create time as access time
- supplement with "refetched" metadata
```js
try {
return versionedCache.get('key')
} catch (e) {
if (e instanceof NeedsRevalidation) {
const res = fetch()
versionedCache.put('key', res)
return res
} else {
throw
}
}
```