@mmstack/resource 20.2.7 → 20.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/mmstack-resource.mjs +143 -14
- package/fesm2022/mmstack-resource.mjs.map +1 -1
- package/index.d.ts +21 -2
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ type OldsetCleanupType = {
|
|
|
40
40
|
type CacheEntry<T> = {
|
|
41
41
|
value: T;
|
|
42
42
|
created: number;
|
|
43
|
+
updated: number;
|
|
43
44
|
stale: number;
|
|
44
45
|
useCount: number;
|
|
45
46
|
expiresAt: number;
|
|
@@ -62,6 +63,12 @@ declare class Cache<T> {
|
|
|
62
63
|
protected readonly staleTime: number;
|
|
63
64
|
private readonly internal;
|
|
64
65
|
private readonly cleanupOpt;
|
|
66
|
+
/**
|
|
67
|
+
* Destroys the cache instance, cleaning up any resources used by the cache.
|
|
68
|
+
* This method is called automatically when the cache instance is garbage collected.
|
|
69
|
+
*/
|
|
70
|
+
readonly destroy: () => void;
|
|
71
|
+
private readonly broadcast;
|
|
65
72
|
/**
|
|
66
73
|
* Creates a new `Cache` instance.
|
|
67
74
|
*
|
|
@@ -70,8 +77,14 @@ declare class Cache<T> {
|
|
|
70
77
|
* stale but can still be used while revalidation occurs in the background. Defaults to 1 hour.
|
|
71
78
|
* @param cleanupOpt - Options for configuring the cache cleanup strategy. Defaults to LRU with a
|
|
72
79
|
* `maxSize` of 200 and a `checkInterval` of one hour.
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
* @param syncTabs - If provided, the cache will use the options a BroadcastChannel to send updates between tabs.
|
|
81
|
+
* Defaults to `undefined`, meaning no synchronization across tabs.
|
|
82
|
+
*/
|
|
83
|
+
constructor(ttl?: number, staleTime?: number, cleanupOpt?: Partial<CleanupType>, syncTabs?: {
|
|
84
|
+
id: string;
|
|
85
|
+
serialize: (value: T) => string;
|
|
86
|
+
deserialize: (value: string) => T | null;
|
|
87
|
+
});
|
|
75
88
|
/** @internal */
|
|
76
89
|
private getInternal;
|
|
77
90
|
/**
|
|
@@ -113,12 +126,14 @@ declare class Cache<T> {
|
|
|
113
126
|
* @param ttl - (Optional) The TTL for this entry, in milliseconds. Overrides the default `ttl`.
|
|
114
127
|
*/
|
|
115
128
|
store(key: string, value: T, staleTime?: number, ttl?: number): void;
|
|
129
|
+
private storeInternal;
|
|
116
130
|
/**
|
|
117
131
|
* Invalidates (removes) a cache entry.
|
|
118
132
|
*
|
|
119
133
|
* @param key - The key of the entry to invalidate.
|
|
120
134
|
*/
|
|
121
135
|
invalidate(key: string): void;
|
|
136
|
+
private invalidateInternal;
|
|
122
137
|
/** @internal */
|
|
123
138
|
private cleanup;
|
|
124
139
|
}
|
|
@@ -139,6 +154,10 @@ type CacheOptions = {
|
|
|
139
154
|
* Options for configuring the cache cleanup strategy.
|
|
140
155
|
*/
|
|
141
156
|
cleanup?: Partial<CleanupType>;
|
|
157
|
+
/**
|
|
158
|
+
* Whether to synchronize cache across tabs. If provided, the cache will use a BroadcastChannel to send updates between tabs.
|
|
159
|
+
*/
|
|
160
|
+
syncTabsId?: string;
|
|
142
161
|
};
|
|
143
162
|
/**
|
|
144
163
|
* Provides the instance of the QueryCache for queryResource. This should probably be called
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mmstack/resource",
|
|
3
|
-
"version": "20.2.
|
|
3
|
+
"version": "20.2.8",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"angular",
|
|
6
6
|
"signals",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"homepage": "https://github.com/mihajm/mmstack/blob/master/packages/resource",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"uuid": "~11.1.0",
|
|
21
|
-
"@mmstack/primitives": "^20.0.
|
|
21
|
+
"@mmstack/primitives": "^20.0.3",
|
|
22
22
|
"@mmstack/object": "^20.0.0",
|
|
23
23
|
"tslib": "^2.3.0"
|
|
24
24
|
},
|