Skip to content

Commit 69a474e

Browse files
committed
docstr
1 parent e50bfab commit 69a474e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/core/src/shared/utilities/resourceCache.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ function now() {
2626
return globals.clock.Date.now()
2727
}
2828

29+
/**
30+
* args:
31+
* key: global state key, which is used for globals.globalState#update, #tryGet etc.
32+
* expirationInMilli: cache expiration time in milli seconds
33+
* defaultValue: default value for the cache if the cache doesn't pre-exist in users' FS
34+
* waitUntilOption: waitUntil option for acquire lock
35+
*
36+
* methods:
37+
* resourceProvider(): implementation needs to implement this method to obtain the latest resource either via network calls or FS read
38+
* getResource(): obtain the resource from cache or pull the latest from the service if the cache either expires or doesn't exist
39+
*/
2940
export abstract class CachedResource<V> {
3041
constructor(
3142
private readonly key: globalKey,
@@ -100,6 +111,7 @@ export abstract class CachedResource<V> {
100111
return lock
101112
}
102113

114+
// TODO: releaseLock and updateCache do similar things, how to improve
103115
async releaseLock() {
104116
await globals.globalState.update(this.key, {
105117
...this.readCacheOrDefault(),

0 commit comments

Comments
 (0)