@fjell/cache 4.6.5 → 4.6.10
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/dist/Cache.cjs.js +41 -2
- package/dist/Cache.es.js +41 -2
- package/dist/CacheMap.cjs.js +65 -3
- package/dist/CacheMap.es.js +65 -3
- package/dist/Instance.cjs.js +27 -0
- package/dist/Instance.d.ts +20 -0
- package/dist/Instance.es.js +22 -0
- package/dist/InstanceFactory.cjs.js +23 -0
- package/dist/InstanceFactory.d.ts +8 -0
- package/dist/InstanceFactory.es.js +19 -0
- package/dist/Registry.cjs.js +36 -0
- package/dist/Registry.d.ts +15 -0
- package/dist/Registry.es.js +31 -0
- package/dist/index.cjs +224 -119
- package/dist/index.cjs.js +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +4 -2
- package/examples/README.md +307 -0
- package/examples/aggregator-example.ts +334 -0
- package/examples/basic-cache-example.ts +273 -0
- package/examples/cache-map-example.ts +265 -0
- package/package.json +13 -12
- package/vitest.config.ts +2 -2
- package/dist/CacheRegistry.cjs.js +0 -66
- package/dist/CacheRegistry.d.ts +0 -10
- package/dist/CacheRegistry.es.js +0 -62
package/dist/CacheRegistry.es.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import LibLogger from './logger.es.js';
|
|
2
|
-
|
|
3
|
-
function _define_property(obj, key, value) {
|
|
4
|
-
if (key in obj) {
|
|
5
|
-
Object.defineProperty(obj, key, {
|
|
6
|
-
value: value,
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true
|
|
10
|
-
});
|
|
11
|
-
} else {
|
|
12
|
-
obj[key] = value;
|
|
13
|
-
}
|
|
14
|
-
return obj;
|
|
15
|
-
}
|
|
16
|
-
const logger = LibLogger.get('CacheRegistry');
|
|
17
|
-
class CacheRegistry {
|
|
18
|
-
constructor(){
|
|
19
|
-
// TODO: My use of Generics has Boxed me into a corner where I can't reference AbstractCache without the types
|
|
20
|
-
_define_property(this, "cacheMap", {});
|
|
21
|
-
_define_property(this, "registerCache", async (cache)=>{
|
|
22
|
-
try {
|
|
23
|
-
logger.debug('Attempting to register cache with pkTypes:', cache.pkTypes);
|
|
24
|
-
const key = JSON.stringify(cache.pkTypes);
|
|
25
|
-
if (this.cacheMap[key]) {
|
|
26
|
-
logger.debug(`Cache with pkTypes ${key} already exists, will be overwritten`);
|
|
27
|
-
}
|
|
28
|
-
this.cacheMap[key] = cache;
|
|
29
|
-
logger.debug('Cache registered successfully with key:', key);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
logger.error('Failed to register cache:', error);
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
_define_property(this, "getCache", (kts)=>{
|
|
36
|
-
logger.debug('Attempting to get cache for key types:', kts);
|
|
37
|
-
const key = JSON.stringify(kts);
|
|
38
|
-
logger.debug('Looking up cache with key:', key);
|
|
39
|
-
const cache = this.cacheMap[key];
|
|
40
|
-
if (!cache) {
|
|
41
|
-
logger.warning(`No cache found for key types: ${key}`);
|
|
42
|
-
}
|
|
43
|
-
return cache;
|
|
44
|
-
});
|
|
45
|
-
_define_property(this, "printRegisteredCaches", ()=>{
|
|
46
|
-
logger.debug('Printing all registered caches:');
|
|
47
|
-
const cacheCount = Object.keys(this.cacheMap).length;
|
|
48
|
-
logger.debug(`Total number of registered caches: ${cacheCount}`);
|
|
49
|
-
if (cacheCount === 0) {
|
|
50
|
-
logger.debug('No caches are currently registered');
|
|
51
|
-
}
|
|
52
|
-
Object.entries(this.cacheMap).forEach(([keyTypes])=>{
|
|
53
|
-
logger.debug(`Cache with key types: ${keyTypes}`);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
logger.debug('CacheRegistry instance created');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
_define_property(CacheRegistry, "instance", void 0);
|
|
60
|
-
|
|
61
|
-
export { CacheRegistry };
|
|
62
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGVSZWdpc3RyeS5lcy5qcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|