@fjell/cache 4.6.22 → 4.7.0
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/CACHE_IMPLEMENTATIONS.md +198 -0
- package/CONFIGURATION_GUIDE.md +167 -0
- package/CRITICAL_FIXES.md +68 -0
- package/README.md +506 -2
- package/debug_test2.js +0 -0
- package/debug_test3.js +0 -0
- package/dist/Cache.d.ts +4 -1
- package/dist/CacheContext.d.ts +27 -0
- package/dist/CacheMap.d.ts +89 -14
- package/dist/Instance.d.ts +4 -2
- package/dist/InstanceFactory.d.ts +3 -2
- package/dist/Operations.d.ts +2 -1
- package/dist/Options.d.ts +100 -0
- package/dist/browser/AsyncIndexDBCacheMap.d.ts +38 -0
- package/dist/browser/IndexDBCacheMap.d.ts +54 -0
- package/dist/browser/LocalStorageCacheMap.d.ts +43 -0
- package/dist/browser/SessionStorageCacheMap.d.ts +35 -0
- package/dist/eviction/EvictionStrategy.d.ts +50 -0
- package/dist/eviction/EvictionStrategyConfig.d.ts +97 -0
- package/dist/eviction/EvictionStrategyFactory.d.ts +12 -0
- package/dist/eviction/EvictionStrategyValidation.d.ts +36 -0
- package/dist/eviction/index.d.ts +9 -0
- package/dist/eviction/strategies/ARCEvictionStrategy.d.ts +68 -0
- package/dist/eviction/strategies/FIFOEvictionStrategy.d.ts +11 -0
- package/dist/eviction/strategies/LFUEvictionStrategy.d.ts +37 -0
- package/dist/eviction/strategies/LRUEvictionStrategy.d.ts +11 -0
- package/dist/eviction/strategies/MRUEvictionStrategy.d.ts +11 -0
- package/dist/eviction/strategies/RandomEvictionStrategy.d.ts +11 -0
- package/dist/eviction/strategies/TwoQueueEvictionStrategy.d.ts +53 -0
- package/dist/index.d.ts +24 -7
- package/dist/index.js +3879 -446
- package/dist/index.js.map +4 -4
- package/dist/memory/EnhancedMemoryCacheMap.d.ts +75 -0
- package/dist/memory/MemoryCacheMap.d.ts +33 -0
- package/dist/normalization.d.ts +20 -0
- package/dist/ops/action.d.ts +2 -3
- package/dist/ops/all.d.ts +2 -3
- package/dist/ops/allAction.d.ts +2 -3
- package/dist/ops/allFacet.d.ts +2 -3
- package/dist/ops/create.d.ts +2 -3
- package/dist/ops/facet.d.ts +2 -3
- package/dist/ops/find.d.ts +2 -3
- package/dist/ops/findOne.d.ts +2 -3
- package/dist/ops/get.d.ts +2 -3
- package/dist/ops/one.d.ts +2 -3
- package/dist/ops/remove.d.ts +2 -3
- package/dist/ops/reset.d.ts +2 -1
- package/dist/ops/retrieve.d.ts +2 -3
- package/dist/ops/set.d.ts +2 -2
- package/dist/ops/update.d.ts +2 -3
- package/dist/utils/CacheSize.d.ts +37 -0
- package/package.json +1 -1
package/dist/CacheMap.d.ts
CHANGED
|
@@ -1,15 +1,90 @@
|
|
|
1
|
-
import { AllItemTypeArrays, ComKey,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { AllItemTypeArrays, ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base interface for cache map implementations.
|
|
4
|
+
* Defines the contract that all cache map implementations must follow.
|
|
5
|
+
*
|
|
6
|
+
* @template V - The type of the data model item, extending Item
|
|
7
|
+
* @template S - The string literal type representing the model's key type
|
|
8
|
+
* @template L1-L5 - Optional string literal types for location hierarchy levels
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class CacheMap<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
|
|
11
|
+
protected types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>;
|
|
12
|
+
constructor(types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>);
|
|
13
|
+
/**
|
|
14
|
+
* Retrieve an item by its key
|
|
15
|
+
*/
|
|
16
|
+
abstract get(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): V | null;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieve an item by its key with TTL awareness
|
|
19
|
+
* Returns null if item doesn't exist or has expired based on the provided TTL
|
|
20
|
+
*/
|
|
21
|
+
abstract getWithTTL(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, ttl: number): V | null;
|
|
22
|
+
/**
|
|
23
|
+
* Store an item with its key
|
|
24
|
+
*/
|
|
25
|
+
abstract set(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, value: V): void;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a key exists in the cache
|
|
28
|
+
*/
|
|
29
|
+
abstract includesKey(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Delete an item by its key
|
|
32
|
+
*/
|
|
33
|
+
abstract delete(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Get all items in the specified locations
|
|
36
|
+
*/
|
|
37
|
+
abstract allIn(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
38
|
+
/**
|
|
39
|
+
* Check if any items match the query in the specified locations
|
|
40
|
+
*/
|
|
41
|
+
abstract contains(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Get all items that match the query in the specified locations
|
|
44
|
+
*/
|
|
45
|
+
abstract queryIn(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
46
|
+
/**
|
|
47
|
+
* Create a clone of this cache map
|
|
48
|
+
*/
|
|
49
|
+
abstract clone(): CacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
50
|
+
/**
|
|
51
|
+
* Get all keys in the cache
|
|
52
|
+
*/
|
|
53
|
+
abstract keys(): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[];
|
|
54
|
+
/**
|
|
55
|
+
* Get all values in the cache
|
|
56
|
+
*/
|
|
57
|
+
abstract values(): V[];
|
|
58
|
+
/**
|
|
59
|
+
* Clear all items from the cache
|
|
60
|
+
*/
|
|
61
|
+
abstract clear(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Set a query result as a collection of item keys
|
|
64
|
+
*/
|
|
65
|
+
abstract setQueryResult(queryHash: string, itemKeys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[], ttl?: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get a query result as a collection of item keys
|
|
68
|
+
*/
|
|
69
|
+
abstract getQueryResult(queryHash: string): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[] | null;
|
|
70
|
+
/**
|
|
71
|
+
* Check if a query result exists in cache
|
|
72
|
+
*/
|
|
73
|
+
abstract hasQueryResult(queryHash: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Delete a specific query result
|
|
76
|
+
*/
|
|
77
|
+
abstract deleteQueryResult(queryHash: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* Invalidate all cached items by their keys
|
|
80
|
+
*/
|
|
81
|
+
abstract invalidateItemKeys(keys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[]): void;
|
|
82
|
+
/**
|
|
83
|
+
* Invalidate all items in specified locations and clear related query results
|
|
84
|
+
*/
|
|
85
|
+
abstract invalidateLocation(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): void;
|
|
86
|
+
/**
|
|
87
|
+
* Clear all query result cache entries
|
|
88
|
+
*/
|
|
89
|
+
abstract clearQueryResults(): void;
|
|
15
90
|
}
|
package/dist/Instance.d.ts
CHANGED
|
@@ -6,12 +6,14 @@ import { Cache } from "./Cache";
|
|
|
6
6
|
* The Cache Instance interface represents a cache model instance that extends the base Instance
|
|
7
7
|
* from @fjell/registry and adds cache operations for interacting with cached data.
|
|
8
8
|
*
|
|
9
|
-
* This is
|
|
9
|
+
* This is a type alias for the Cache interface. Both Cache and Instance refer to the same
|
|
10
|
+
* cache interface - Instance exists for backward compatibility and consistency with other
|
|
11
|
+
* Fjell packages that export Instance types.
|
|
10
12
|
*
|
|
11
13
|
* @template V - The type of the data model item, extending Item
|
|
12
14
|
* @template S - The string literal type representing the model's key type
|
|
13
15
|
* @template L1-L5 - Optional string literal types for location hierarchy levels
|
|
14
16
|
*/
|
|
15
17
|
export type Instance<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> = Cache<V, S, L1, L2, L3, L4, L5>;
|
|
16
|
-
export declare const createInstance: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(registry: Registry, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, api: ClientApi<V, S, L1, L2, L3, L4, L5
|
|
18
|
+
export declare const createInstance: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(registry: Registry, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, api: ClientApi<V, S, L1, L2, L3, L4, L5>, options?: Partial<import("./Options").Options<V, S, L1, L2, L3, L4, L5>>) => Instance<V, S, L1, L2, L3, L4, L5>;
|
|
17
19
|
export declare const isInstance: (instance: any) => instance is Instance<any, any, any, any, any, any, any>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Item } from "@fjell/core";
|
|
2
2
|
import { ClientApi } from "@fjell/client-api";
|
|
3
3
|
import { InstanceFactory as BaseInstanceFactory } from "@fjell/registry";
|
|
4
|
-
|
|
4
|
+
import { Options } from "./Options";
|
|
5
|
+
export type InstanceFactory<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> = (api: ClientApi<V, S, L1, L2, L3, L4, L5>, options?: Partial<Options<V, S, L1, L2, L3, L4, L5>>) => BaseInstanceFactory<S, L1, L2, L3, L4, L5>;
|
|
5
6
|
/**
|
|
6
7
|
* Factory function for creating cache instances
|
|
7
8
|
*/
|
|
8
|
-
export declare const createInstanceFactory: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(api: ClientApi<V, S, L1, L2, L3, L4, L5
|
|
9
|
+
export declare const createInstanceFactory: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(api: ClientApi<V, S, L1, L2, L3, L4, L5>, options?: Partial<Options<V, S, L1, L2, L3, L4, L5>>) => BaseInstanceFactory<S, L1, L2, L3, L4, L5>;
|
package/dist/Operations.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
|
2
2
|
import { ClientApi } from "@fjell/client-api";
|
|
3
3
|
import { Coordinate } from "@fjell/registry";
|
|
4
4
|
import { CacheMap } from "./CacheMap";
|
|
5
|
+
import { Options } from "./Options";
|
|
5
6
|
export interface Operations<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
|
|
6
7
|
/**
|
|
7
8
|
* Retrieves all the items that match the query from cache or API.
|
|
@@ -67,4 +68,4 @@ export interface Operations<V extends Item<S, L1, L2, L3, L4, L5>, S extends str
|
|
|
67
68
|
*/
|
|
68
69
|
reset(): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]>;
|
|
69
70
|
}
|
|
70
|
-
export declare const createOperations: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(api: ClientApi<V, S, L1, L2, L3, L4, L5>, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S) => Operations<V, S, L1, L2, L3, L4, L5>;
|
|
71
|
+
export declare const createOperations: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(api: ClientApi<V, S, L1, L2, L3, L4, L5>, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, options: Options<V, S, L1, L2, L3, L4, L5>) => Operations<V, S, L1, L2, L3, L4, L5>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Item } from '@fjell/core';
|
|
2
|
+
import { CacheMap } from './CacheMap';
|
|
3
|
+
import { EvictionStrategyConfigs } from './eviction/EvictionStrategyConfig';
|
|
4
|
+
/**
|
|
5
|
+
* Available cache types for the cache instance
|
|
6
|
+
*/
|
|
7
|
+
export type CacheType = 'memory' | 'localStorage' | 'sessionStorage' | 'indexedDB' | 'asyncIndexedDB' | 'custom';
|
|
8
|
+
/**
|
|
9
|
+
* Cache eviction policies for when cache size limits are reached
|
|
10
|
+
*/
|
|
11
|
+
export type EvictionPolicy = 'lru' | 'lfu' | 'fifo' | 'mru' | 'random' | 'arc' | '2q';
|
|
12
|
+
/**
|
|
13
|
+
* Cache size configuration supporting bytes and item count limits
|
|
14
|
+
*/
|
|
15
|
+
export interface CacheSizeConfig {
|
|
16
|
+
/** Maximum cache size in bytes (e.g., '100', '5KB', '10MB', '2GB', '1KiB', '512MiB') */
|
|
17
|
+
maxSizeBytes?: string;
|
|
18
|
+
/** Maximum number of items in cache */
|
|
19
|
+
maxItems?: number;
|
|
20
|
+
/** Eviction policy to use when limits are exceeded (default: 'lru') */
|
|
21
|
+
evictionPolicy?: EvictionPolicy;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for IndexedDB-based cache maps
|
|
25
|
+
*/
|
|
26
|
+
export interface IndexedDBConfig {
|
|
27
|
+
/** Database name (default: 'fjell-cache') */
|
|
28
|
+
dbName?: string;
|
|
29
|
+
/** Database version (default: 1) */
|
|
30
|
+
version?: number;
|
|
31
|
+
/** Object store name (default: 'cache') */
|
|
32
|
+
storeName?: string;
|
|
33
|
+
/** Size configuration for IndexedDB cache */
|
|
34
|
+
size?: CacheSizeConfig;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for localStorage/sessionStorage-based cache maps
|
|
38
|
+
*/
|
|
39
|
+
export interface WebStorageConfig {
|
|
40
|
+
/** Key prefix for storage items (default: 'fjell-cache:') */
|
|
41
|
+
keyPrefix?: string;
|
|
42
|
+
/** Whether to compress stored data (default: false) */
|
|
43
|
+
compress?: boolean;
|
|
44
|
+
/** Size configuration for web storage cache */
|
|
45
|
+
size?: CacheSizeConfig;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Configuration for memory-based cache maps
|
|
49
|
+
*/
|
|
50
|
+
export interface MemoryConfig {
|
|
51
|
+
/** Maximum number of items to keep in memory (default: unlimited) */
|
|
52
|
+
maxItems?: number;
|
|
53
|
+
/** Time to live for cached items in milliseconds (default: unlimited) */
|
|
54
|
+
ttl?: number;
|
|
55
|
+
/** Size configuration for memory cache */
|
|
56
|
+
size?: CacheSizeConfig;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Factory function for creating custom cache map instances
|
|
60
|
+
*/
|
|
61
|
+
export type CacheMapFactory<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> = (kta: [S, ...string[]]) => CacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
62
|
+
/**
|
|
63
|
+
* Cache options interface for configuring cache instances
|
|
64
|
+
*/
|
|
65
|
+
export interface Options<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
|
|
66
|
+
/** The type of cache to use */
|
|
67
|
+
cacheType: CacheType;
|
|
68
|
+
/** Configuration for IndexedDB cache types */
|
|
69
|
+
indexedDBConfig?: IndexedDBConfig;
|
|
70
|
+
/** Configuration for web storage cache types */
|
|
71
|
+
webStorageConfig?: WebStorageConfig;
|
|
72
|
+
/** Configuration for memory cache type */
|
|
73
|
+
memoryConfig?: MemoryConfig;
|
|
74
|
+
/** Custom cache map factory for 'custom' cache type */
|
|
75
|
+
customCacheMapFactory?: CacheMapFactory<V, S, L1, L2, L3, L4, L5>;
|
|
76
|
+
/** Eviction strategy configuration - independent of cache implementation */
|
|
77
|
+
evictionConfig?: EvictionStrategyConfigs;
|
|
78
|
+
/** Whether to enable debug logging for cache operations */
|
|
79
|
+
enableDebugLogging?: boolean;
|
|
80
|
+
/** Whether to automatically sync with the API on cache misses */
|
|
81
|
+
autoSync?: boolean;
|
|
82
|
+
/** Cache expiration time in milliseconds (default: unlimited) */
|
|
83
|
+
ttl?: number;
|
|
84
|
+
/** Maximum number of retry attempts for failed operations */
|
|
85
|
+
maxRetries?: number;
|
|
86
|
+
/** Delay between retry attempts in milliseconds */
|
|
87
|
+
retryDelay?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create cache options with defaults
|
|
91
|
+
*/
|
|
92
|
+
export declare const createOptions: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(cacheOptions?: Partial<Options<V, S, L1, L2, L3, L4, L5>>) => Options<V, S, L1, L2, L3, L4, L5>;
|
|
93
|
+
/**
|
|
94
|
+
* Create a cache map instance based on the provided options
|
|
95
|
+
*/
|
|
96
|
+
export declare const createCacheMap: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(kta: [S, ...string[]], options: Options<V, S, L1, L2, L3, L4, L5>) => CacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
97
|
+
/**
|
|
98
|
+
* Validate cache options
|
|
99
|
+
*/
|
|
100
|
+
export declare const validateOptions: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(options: Options<V, S, L1, L2, L3, L4, L5>) => void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AllItemTypeArrays, ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
2
|
+
/**
|
|
3
|
+
* IndexedDB implementation of CacheMap for browser environments.
|
|
4
|
+
* Data persists long-term with much larger storage limits than localStorage/sessionStorage.
|
|
5
|
+
*
|
|
6
|
+
* Note: IndexedDB is asynchronous and can store structured data.
|
|
7
|
+
* Storage limit is hundreds of MB or more depending on browser and user.
|
|
8
|
+
* This implementation uses promises for all operations.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AsyncIndexDBCacheMap<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
|
|
11
|
+
protected types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>;
|
|
12
|
+
private dbName;
|
|
13
|
+
private storeName;
|
|
14
|
+
private version;
|
|
15
|
+
private normalizedHashFunction;
|
|
16
|
+
private dbPromise;
|
|
17
|
+
constructor(types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>, dbName?: string, storeName?: string, version?: number);
|
|
18
|
+
private getDB;
|
|
19
|
+
private getStorageKey;
|
|
20
|
+
get(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): Promise<V | null>;
|
|
21
|
+
set(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, value: V): Promise<void>;
|
|
22
|
+
includesKey(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): Promise<boolean>;
|
|
23
|
+
delete(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): Promise<void>;
|
|
24
|
+
allIn(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V[]>;
|
|
25
|
+
contains(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<boolean>;
|
|
26
|
+
queryIn(query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V[]>;
|
|
27
|
+
clone(): AsyncIndexDBCacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
28
|
+
keys(): Promise<(ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[]>;
|
|
29
|
+
values(): Promise<V[]>;
|
|
30
|
+
clear(): Promise<void>;
|
|
31
|
+
setQueryResult(queryHash: string, itemKeys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[], ttl?: number): Promise<void>;
|
|
32
|
+
getQueryResult(queryHash: string): Promise<(ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[] | null>;
|
|
33
|
+
hasQueryResult(queryHash: string): Promise<boolean>;
|
|
34
|
+
deleteQueryResult(queryHash: string): Promise<void>;
|
|
35
|
+
invalidateItemKeys(keys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[]): Promise<void>;
|
|
36
|
+
invalidateLocation(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<void>;
|
|
37
|
+
clearQueryResults(): Promise<void>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AllItemTypeArrays, ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
2
|
+
import { CacheMap } from "../CacheMap";
|
|
3
|
+
import { AsyncIndexDBCacheMap } from "./AsyncIndexDBCacheMap";
|
|
4
|
+
/**
|
|
5
|
+
* Synchronous wrapper for IndexedDB CacheMap implementation.
|
|
6
|
+
*
|
|
7
|
+
* This implementation provides a synchronous interface over IndexedDB
|
|
8
|
+
* by maintaining an in-memory cache that is periodically synchronized
|
|
9
|
+
* with IndexedDB storage. For full async capabilities, use AsyncIndexDBCacheMap.
|
|
10
|
+
*
|
|
11
|
+
* Note: This class maintains synchronous compatibility while providing
|
|
12
|
+
* persistent storage benefits of IndexedDB.
|
|
13
|
+
*/
|
|
14
|
+
export declare class IndexDBCacheMap<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends CacheMap<V, S, L1, L2, L3, L4, L5> {
|
|
15
|
+
asyncCache: AsyncIndexDBCacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
16
|
+
private memoryCache;
|
|
17
|
+
private syncInterval;
|
|
18
|
+
private readonly SYNC_INTERVAL_MS;
|
|
19
|
+
private pendingSyncOperations;
|
|
20
|
+
private initializationPromise;
|
|
21
|
+
private isInitialized;
|
|
22
|
+
private readonly MAX_RETRY_ATTEMPTS;
|
|
23
|
+
constructor(types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>, dbName?: string, storeName?: string, version?: number);
|
|
24
|
+
private initializeFromIndexedDB;
|
|
25
|
+
private startPeriodicSync;
|
|
26
|
+
private syncToIndexedDB;
|
|
27
|
+
private processPendingOperations;
|
|
28
|
+
private queueForSync;
|
|
29
|
+
private queueDeleteForSync;
|
|
30
|
+
private queueClearForSync;
|
|
31
|
+
get(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): V | null;
|
|
32
|
+
getWithTTL(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, ttl: number): V | null;
|
|
33
|
+
set(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, value: V): void;
|
|
34
|
+
includesKey(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): boolean;
|
|
35
|
+
delete(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): void;
|
|
36
|
+
allIn(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
37
|
+
contains(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): boolean;
|
|
38
|
+
queryIn(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
39
|
+
clone(): IndexDBCacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
40
|
+
keys(): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[];
|
|
41
|
+
values(): V[];
|
|
42
|
+
clear(): void;
|
|
43
|
+
setQueryResult(queryHash: string, itemKeys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[], ttl?: number): void;
|
|
44
|
+
getQueryResult(queryHash: string): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[] | null;
|
|
45
|
+
hasQueryResult(queryHash: string): boolean;
|
|
46
|
+
deleteQueryResult(queryHash: string): void;
|
|
47
|
+
invalidateItemKeys(keys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[]): void;
|
|
48
|
+
invalidateLocation(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): void;
|
|
49
|
+
clearQueryResults(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Clean up resources when the cache is no longer needed
|
|
52
|
+
*/
|
|
53
|
+
destroy(): void;
|
|
54
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AllItemTypeArrays, ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
2
|
+
import { CacheMap } from "../CacheMap";
|
|
3
|
+
/**
|
|
4
|
+
* LocalStorage implementation of CacheMap for browser environments.
|
|
5
|
+
* Data persists across browser sessions and page reloads.
|
|
6
|
+
*
|
|
7
|
+
* Note: LocalStorage has a ~5-10MB limit and stores strings only.
|
|
8
|
+
* Data is synchronous and survives browser restarts.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LocalStorageCacheMap<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends CacheMap<V, S, L1, L2, L3, L4, L5> {
|
|
11
|
+
private keyPrefix;
|
|
12
|
+
private normalizedHashFunction;
|
|
13
|
+
private fallbackCache;
|
|
14
|
+
private quotaExceeded;
|
|
15
|
+
constructor(types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>, keyPrefix?: string);
|
|
16
|
+
private getStorageKey;
|
|
17
|
+
private initializeFallbackCache;
|
|
18
|
+
private isQuotaExceededError;
|
|
19
|
+
private tryCleanupOldEntries;
|
|
20
|
+
private collectCacheEntries;
|
|
21
|
+
private removeOldestEntries;
|
|
22
|
+
private getAllStorageKeys;
|
|
23
|
+
get(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): V | null;
|
|
24
|
+
getWithTTL(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, ttl: number): V | null;
|
|
25
|
+
set(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, value: V): void;
|
|
26
|
+
includesKey(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): boolean;
|
|
27
|
+
delete(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): void;
|
|
28
|
+
allIn(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
29
|
+
contains(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): boolean;
|
|
30
|
+
queryIn(query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
31
|
+
clone(): LocalStorageCacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
32
|
+
private parseStorageEntry;
|
|
33
|
+
keys(): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[];
|
|
34
|
+
values(): V[];
|
|
35
|
+
clear(): void;
|
|
36
|
+
setQueryResult(queryHash: string, itemKeys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[], ttl?: number): void;
|
|
37
|
+
getQueryResult(queryHash: string): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[] | null;
|
|
38
|
+
hasQueryResult(queryHash: string): boolean;
|
|
39
|
+
deleteQueryResult(queryHash: string): void;
|
|
40
|
+
invalidateItemKeys(keys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[]): void;
|
|
41
|
+
invalidateLocation(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): void;
|
|
42
|
+
clearQueryResults(): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AllItemTypeArrays, ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
2
|
+
import { CacheMap } from "../CacheMap";
|
|
3
|
+
/**
|
|
4
|
+
* SessionStorage implementation of CacheMap for browser environments.
|
|
5
|
+
* Data persists only for the current browser tab/session.
|
|
6
|
+
*
|
|
7
|
+
* Note: SessionStorage has a ~5MB limit and stores strings only.
|
|
8
|
+
* Data is synchronous but is lost when the tab is closed.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SessionStorageCacheMap<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends CacheMap<V, S, L1, L2, L3, L4, L5> {
|
|
11
|
+
private keyPrefix;
|
|
12
|
+
private normalizedHashFunction;
|
|
13
|
+
constructor(types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>, keyPrefix?: string);
|
|
14
|
+
private getStorageKey;
|
|
15
|
+
private getAllStorageKeys;
|
|
16
|
+
get(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): V | null;
|
|
17
|
+
getWithTTL(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, ttl: number): V | null;
|
|
18
|
+
set(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, value: V): void;
|
|
19
|
+
includesKey(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): boolean;
|
|
20
|
+
delete(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): void;
|
|
21
|
+
allIn(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
22
|
+
contains(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): boolean;
|
|
23
|
+
queryIn(query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
24
|
+
clone(): SessionStorageCacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
25
|
+
keys(): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[];
|
|
26
|
+
values(): V[];
|
|
27
|
+
clear(): void;
|
|
28
|
+
setQueryResult(queryHash: string, itemKeys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[], ttl?: number): void;
|
|
29
|
+
getQueryResult(queryHash: string): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[] | null;
|
|
30
|
+
hasQueryResult(queryHash: string): boolean;
|
|
31
|
+
deleteQueryResult(queryHash: string): void;
|
|
32
|
+
invalidateItemKeys(keys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[]): void;
|
|
33
|
+
invalidateLocation(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): void;
|
|
34
|
+
clearQueryResults(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata for tracking cache item usage patterns
|
|
3
|
+
*/
|
|
4
|
+
export interface CacheItemMetadata {
|
|
5
|
+
/** When the item was first added to cache */
|
|
6
|
+
addedAt: number;
|
|
7
|
+
/** When the item was last accessed */
|
|
8
|
+
lastAccessedAt: number;
|
|
9
|
+
/** Number of times the item has been accessed */
|
|
10
|
+
accessCount: number;
|
|
11
|
+
/** Estimated size of the item in bytes */
|
|
12
|
+
estimatedSize: number;
|
|
13
|
+
/** Item key for identification */
|
|
14
|
+
key: string;
|
|
15
|
+
/** Frequency score with decay applied (for LFU with sketching) */
|
|
16
|
+
frequencyScore?: number;
|
|
17
|
+
/** Last time frequency was updated (for decay calculations) */
|
|
18
|
+
lastFrequencyUpdate?: number;
|
|
19
|
+
/** Raw frequency count before decay */
|
|
20
|
+
rawFrequency?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Abstract base class for cache eviction strategies.
|
|
24
|
+
* Defines the core contract that all eviction policies must implement.
|
|
25
|
+
*/
|
|
26
|
+
export declare abstract class EvictionStrategy {
|
|
27
|
+
/**
|
|
28
|
+
* Select which item should be evicted based on the strategy
|
|
29
|
+
* @param items - Map of items with their metadata
|
|
30
|
+
* @returns Key of the item to evict, or null if no eviction needed
|
|
31
|
+
*/
|
|
32
|
+
abstract selectForEviction(items: Map<string, CacheItemMetadata>): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Update metadata when an item is accessed
|
|
35
|
+
* @param key - Item key
|
|
36
|
+
* @param metadata - Current metadata
|
|
37
|
+
*/
|
|
38
|
+
abstract onItemAccessed(key: string, metadata: CacheItemMetadata): void;
|
|
39
|
+
/**
|
|
40
|
+
* Update metadata when an item is added
|
|
41
|
+
* @param key - Item key
|
|
42
|
+
* @param metadata - Initial metadata
|
|
43
|
+
*/
|
|
44
|
+
abstract onItemAdded(key: string, metadata: CacheItemMetadata): void;
|
|
45
|
+
/**
|
|
46
|
+
* Clean up when an item is removed
|
|
47
|
+
* @param key - Item key (optional for some strategies)
|
|
48
|
+
*/
|
|
49
|
+
abstract onItemRemoved(key?: string): void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base configuration interface for eviction strategies
|
|
3
|
+
*/
|
|
4
|
+
export interface EvictionStrategyConfig {
|
|
5
|
+
/** Strategy type identifier */
|
|
6
|
+
readonly type: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for LFU eviction strategy with frequency sketching
|
|
10
|
+
*/
|
|
11
|
+
export interface LFUConfig extends EvictionStrategyConfig {
|
|
12
|
+
readonly type: 'lfu';
|
|
13
|
+
/** Decay factor for aging frequency counts (0.0 to 1.0, default: 0.1) */
|
|
14
|
+
decayFactor?: number;
|
|
15
|
+
/** Frequency decay interval in milliseconds (default: 60000) */
|
|
16
|
+
decayInterval?: number;
|
|
17
|
+
/** Width of the Count-Min Sketch (default: 1024) */
|
|
18
|
+
sketchWidth?: number;
|
|
19
|
+
/** Depth of the Count-Min Sketch (default: 4) */
|
|
20
|
+
sketchDepth?: number;
|
|
21
|
+
/** Whether to use probabilistic counting (default: true) */
|
|
22
|
+
useProbabilisticCounting?: boolean;
|
|
23
|
+
/** Minimum frequency threshold before decay (default: 1) */
|
|
24
|
+
minFrequencyThreshold?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for LRU eviction strategy
|
|
28
|
+
*/
|
|
29
|
+
export interface LRUConfig extends EvictionStrategyConfig {
|
|
30
|
+
readonly type: 'lru';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Configuration for FIFO eviction strategy
|
|
34
|
+
*/
|
|
35
|
+
export interface FIFOConfig extends EvictionStrategyConfig {
|
|
36
|
+
readonly type: 'fifo';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for MRU eviction strategy
|
|
40
|
+
*/
|
|
41
|
+
export interface MRUConfig extends EvictionStrategyConfig {
|
|
42
|
+
readonly type: 'mru';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Configuration for Random eviction strategy
|
|
46
|
+
*/
|
|
47
|
+
export interface RandomConfig extends EvictionStrategyConfig {
|
|
48
|
+
readonly type: 'random';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for ARC eviction strategy
|
|
52
|
+
*/
|
|
53
|
+
export interface ARCConfig extends EvictionStrategyConfig {
|
|
54
|
+
readonly type: 'arc';
|
|
55
|
+
/** Maximum cache size for ARC calculations */
|
|
56
|
+
maxCacheSize?: number;
|
|
57
|
+
/** Frequency threshold for classifying items as "frequent" vs "recent" (default: 2) */
|
|
58
|
+
frequencyThreshold?: number;
|
|
59
|
+
/** Use enhanced frequency tracking with decay (default: true) */
|
|
60
|
+
useEnhancedFrequency?: boolean;
|
|
61
|
+
/** Decay factor for aging frequency scores (default: 0.05) */
|
|
62
|
+
frequencyDecayFactor?: number;
|
|
63
|
+
/** Decay interval for frequency scores (default: 600000 - 10 minutes) */
|
|
64
|
+
frequencyDecayInterval?: number;
|
|
65
|
+
/** Use frequency-weighted selection within T1/T2 lists (default: true) */
|
|
66
|
+
useFrequencyWeightedSelection?: boolean;
|
|
67
|
+
/** Adaptive learning rate for target size adjustments (default: 1.0) */
|
|
68
|
+
adaptiveLearningRate?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for 2Q eviction strategy
|
|
72
|
+
*/
|
|
73
|
+
export interface TwoQueueConfig extends EvictionStrategyConfig {
|
|
74
|
+
readonly type: '2q';
|
|
75
|
+
/** Maximum cache size for 2Q calculations */
|
|
76
|
+
maxCacheSize?: number;
|
|
77
|
+
/** Use frequency-based promotion from recent to hot queue (default: true) */
|
|
78
|
+
useFrequencyPromotion?: boolean;
|
|
79
|
+
/** Minimum access frequency required for promotion to hot queue (default: 2) */
|
|
80
|
+
promotionThreshold?: number;
|
|
81
|
+
/** Decay factor for aging frequency scores in hot queue (default: 0.05) */
|
|
82
|
+
hotQueueDecayFactor?: number;
|
|
83
|
+
/** Decay interval for hot queue frequency scores (default: 300000 - 5 minutes) */
|
|
84
|
+
hotQueueDecayInterval?: number;
|
|
85
|
+
/** Use frequency-weighted LRU in hot queue instead of pure LRU (default: true) */
|
|
86
|
+
useFrequencyWeightedLRU?: boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Union type for all eviction strategy configurations
|
|
90
|
+
*/
|
|
91
|
+
export type EvictionStrategyConfigs = LFUConfig | LRUConfig | FIFOConfig | MRUConfig | RandomConfig | ARCConfig | TwoQueueConfig;
|
|
92
|
+
/**
|
|
93
|
+
* Default configuration values
|
|
94
|
+
*/
|
|
95
|
+
export declare const DEFAULT_LFU_CONFIG: LFUConfig;
|
|
96
|
+
export declare const DEFAULT_ARC_CONFIG: ARCConfig;
|
|
97
|
+
export declare const DEFAULT_TWO_QUEUE_CONFIG: TwoQueueConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EvictionPolicy } from '../Options';
|
|
2
|
+
import { EvictionStrategy } from './EvictionStrategy';
|
|
3
|
+
import { EvictionStrategyConfigs } from './EvictionStrategyConfig';
|
|
4
|
+
/**
|
|
5
|
+
* Factory function to create eviction strategy instances with configuration
|
|
6
|
+
*/
|
|
7
|
+
export declare function createEvictionStrategy(policy: EvictionPolicy, maxCacheSize?: number, config?: EvictionStrategyConfigs): EvictionStrategy;
|
|
8
|
+
/**
|
|
9
|
+
* Factory function for backwards compatibility
|
|
10
|
+
* @deprecated Use createEvictionStrategy with config parameter instead
|
|
11
|
+
*/
|
|
12
|
+
export declare function createEvictionStrategyLegacy(policy: EvictionPolicy, maxCacheSize?: number): EvictionStrategy;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation functions for eviction strategy configurations
|
|
3
|
+
*/
|
|
4
|
+
import { ARCConfig, EvictionStrategyConfigs, LFUConfig, TwoQueueConfig } from './EvictionStrategyConfig';
|
|
5
|
+
/**
|
|
6
|
+
* Sanitizes LFU configuration parameters, correcting invalid values
|
|
7
|
+
*/
|
|
8
|
+
export declare function sanitizeLFUConfig(config: Partial<LFUConfig>): Partial<LFUConfig>;
|
|
9
|
+
/**
|
|
10
|
+
* Validates LFU configuration parameters (after sanitization)
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateLFUConfig(config: Partial<LFUConfig>): void;
|
|
13
|
+
/**
|
|
14
|
+
* Sanitizes ARC configuration parameters, correcting invalid values
|
|
15
|
+
*/
|
|
16
|
+
export declare function sanitizeARCConfig(config: Partial<ARCConfig>): Partial<ARCConfig>;
|
|
17
|
+
/**
|
|
18
|
+
* Validates ARC configuration parameters (after sanitization)
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateARCConfig(config: Partial<ARCConfig>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Sanitizes TwoQueue configuration parameters, correcting invalid values
|
|
23
|
+
*/
|
|
24
|
+
export declare function sanitizeTwoQueueConfig(config: Partial<TwoQueueConfig>): Partial<TwoQueueConfig>;
|
|
25
|
+
/**
|
|
26
|
+
* Validates TwoQueue configuration parameters (after sanitization)
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateTwoQueueConfig(config: Partial<TwoQueueConfig>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Validates any eviction strategy configuration
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateEvictionStrategyConfig(config: Partial<EvictionStrategyConfigs>): void;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a validated configuration with defaults applied and invalid values sanitized
|
|
35
|
+
*/
|
|
36
|
+
export declare function createValidatedConfig<T extends EvictionStrategyConfigs>(baseConfig: T, userConfig: Partial<T>): T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { EvictionStrategy, CacheItemMetadata } from './EvictionStrategy';
|
|
2
|
+
export { createEvictionStrategy } from './EvictionStrategyFactory';
|
|
3
|
+
export { LRUEvictionStrategy } from './strategies/LRUEvictionStrategy';
|
|
4
|
+
export { LFUEvictionStrategy } from './strategies/LFUEvictionStrategy';
|
|
5
|
+
export { FIFOEvictionStrategy } from './strategies/FIFOEvictionStrategy';
|
|
6
|
+
export { MRUEvictionStrategy } from './strategies/MRUEvictionStrategy';
|
|
7
|
+
export { RandomEvictionStrategy } from './strategies/RandomEvictionStrategy';
|
|
8
|
+
export { ARCEvictionStrategy } from './strategies/ARCEvictionStrategy';
|
|
9
|
+
export { TwoQueueEvictionStrategy } from './strategies/TwoQueueEvictionStrategy';
|