@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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { AllItemTypeArrays, ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
2
|
+
import { CacheMap } from "../CacheMap";
|
|
3
|
+
import { CacheSizeConfig } from "../Options";
|
|
4
|
+
/**
|
|
5
|
+
* Enhanced in-memory implementation of CacheMap with size limits and eviction policies.
|
|
6
|
+
* Supports byte-based and item-count limits with configurable eviction strategies.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EnhancedMemoryCacheMap<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> {
|
|
9
|
+
private map;
|
|
10
|
+
private normalizedHashFunction;
|
|
11
|
+
private queryResultCache;
|
|
12
|
+
private ttlOperationsInProgress;
|
|
13
|
+
private currentSizeBytes;
|
|
14
|
+
private currentItemCount;
|
|
15
|
+
private queryResultsCacheSize;
|
|
16
|
+
private readonly maxSizeBytes?;
|
|
17
|
+
private readonly maxItems?;
|
|
18
|
+
private readonly evictionStrategy;
|
|
19
|
+
constructor(types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>, sizeConfig?: CacheSizeConfig, initialData?: {
|
|
20
|
+
[key: string]: V;
|
|
21
|
+
});
|
|
22
|
+
get(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): V | null;
|
|
23
|
+
getWithTTL(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, ttl: number): V | null;
|
|
24
|
+
set(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, value: V): void;
|
|
25
|
+
includesKey(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): boolean;
|
|
26
|
+
delete(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): void;
|
|
27
|
+
keys(): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[];
|
|
28
|
+
values(): V[];
|
|
29
|
+
clear(): void;
|
|
30
|
+
allIn(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
31
|
+
contains(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): boolean;
|
|
32
|
+
queryIn(query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
33
|
+
clone(): EnhancedMemoryCacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
34
|
+
/**
|
|
35
|
+
* Get current cache statistics
|
|
36
|
+
*/
|
|
37
|
+
getStats(): {
|
|
38
|
+
currentSizeBytes: number;
|
|
39
|
+
currentItemCount: number;
|
|
40
|
+
maxSizeBytes?: number;
|
|
41
|
+
maxItems?: number;
|
|
42
|
+
utilizationPercent: {
|
|
43
|
+
bytes?: number;
|
|
44
|
+
items?: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Ensure there's space available for a new item of the given size
|
|
49
|
+
* Evicts items if necessary based on the configured eviction policy
|
|
50
|
+
*/
|
|
51
|
+
private ensureSpaceAvailable;
|
|
52
|
+
/**
|
|
53
|
+
* Evict a specific item and update metadata tracking
|
|
54
|
+
*/
|
|
55
|
+
private evictItem;
|
|
56
|
+
setQueryResult(queryHash: string, itemKeys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[], ttl?: number): void;
|
|
57
|
+
getQueryResult(queryHash: string): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[] | null;
|
|
58
|
+
hasQueryResult(queryHash: string): boolean;
|
|
59
|
+
deleteQueryResult(queryHash: string): void;
|
|
60
|
+
clearQueryResults(): void;
|
|
61
|
+
invalidateItemKeys(keys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[]): void;
|
|
62
|
+
invalidateLocation(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): void;
|
|
63
|
+
/**
|
|
64
|
+
* Add query result to size tracking
|
|
65
|
+
*/
|
|
66
|
+
private addQueryResultToSizeTracking;
|
|
67
|
+
/**
|
|
68
|
+
* Remove query result from size tracking
|
|
69
|
+
*/
|
|
70
|
+
private removeQueryResultFromSizeTracking;
|
|
71
|
+
/**
|
|
72
|
+
* Get total cache size including query results
|
|
73
|
+
*/
|
|
74
|
+
getTotalSizeBytes(): number;
|
|
75
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AllItemTypeArrays, ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
2
|
+
import { CacheMap } from "../CacheMap";
|
|
3
|
+
/**
|
|
4
|
+
* In-memory implementation of CacheMap using a plain object as the underlying storage.
|
|
5
|
+
* This implementation stores all data in memory and will be lost when the application restarts.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MemoryCacheMap<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> {
|
|
8
|
+
private map;
|
|
9
|
+
private normalizedHashFunction;
|
|
10
|
+
private queryResultCache;
|
|
11
|
+
constructor(types: AllItemTypeArrays<S, L1, L2, L3, L4, L5>, initialData?: {
|
|
12
|
+
[key: string]: V;
|
|
13
|
+
});
|
|
14
|
+
get(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): V | null;
|
|
15
|
+
getWithTTL(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, ttl: number): V | null;
|
|
16
|
+
set(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, value: V): void;
|
|
17
|
+
includesKey(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): boolean;
|
|
18
|
+
delete(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): void;
|
|
19
|
+
keys(): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[];
|
|
20
|
+
values(): V[];
|
|
21
|
+
clear(): void;
|
|
22
|
+
allIn(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
23
|
+
contains(query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []): boolean;
|
|
24
|
+
queryIn(query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): V[];
|
|
25
|
+
clone(): MemoryCacheMap<V, S, L1, L2, L3, L4, L5>;
|
|
26
|
+
setQueryResult(queryHash: string, itemKeys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[], ttl?: number): void;
|
|
27
|
+
getQueryResult(queryHash: string): (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[] | null;
|
|
28
|
+
hasQueryResult(queryHash: string): boolean;
|
|
29
|
+
deleteQueryResult(queryHash: string): void;
|
|
30
|
+
invalidateItemKeys(keys: (ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>)[]): void;
|
|
31
|
+
invalidateLocation(locations: LocKeyArray<L1, L2, L3, L4, L5> | []): void;
|
|
32
|
+
clearQueryResults(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ItemQuery, LocKeyArray } from "@fjell/core";
|
|
2
|
+
export declare const normalizeKeyValue: (value: string | number) => string;
|
|
3
|
+
export declare const createNormalizedHashFunction: <T>() => (key: T) => string;
|
|
4
|
+
export declare const isLocKeyArrayEqual: (a: any[], b: any[]) => boolean;
|
|
5
|
+
export declare const normalizeLocKeyItem: (item: any) => any;
|
|
6
|
+
/**
|
|
7
|
+
* Interface for storing query results with expiration
|
|
8
|
+
*/
|
|
9
|
+
export interface QueryCacheEntry {
|
|
10
|
+
itemKeys: (any)[];
|
|
11
|
+
expiresAt?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate a safe hash for all/one query parameters
|
|
15
|
+
*/
|
|
16
|
+
export declare const createQueryHash: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(pkType: S, query: ItemQuery, locations: LocKeyArray<L1, L2, L3, L4, L5> | []) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Generate a safe hash for find/findOne query parameters
|
|
19
|
+
*/
|
|
20
|
+
export declare const createFinderHash: <L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(finder: string, params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations: LocKeyArray<L1, L2, L3, L4, L5> | []) => string;
|
package/dist/ops/action.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ComKey, Item, PriKey } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const action: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body?: any) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const action: <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>(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V]>;
|
package/dist/ops/all.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Item, ItemQuery, LocKeyArray } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const all: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const all: <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>(query: ItemQuery | undefined, locations: (LocKeyArray<L1, L2, L3, L4, L5> | []) | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
package/dist/ops/allAction.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Item, LocKeyArray } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const allAction: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, action: string, body?: any, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const allAction: <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>(action: string, body: any | undefined, locations: (LocKeyArray<L1, L2, L3, L4, L5> | []) | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
package/dist/ops/allFacet.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Item, LocKeyArray } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const allFacet: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const allFacet: <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>(facet: string, params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> | undefined, locations: (LocKeyArray<L1, L2, L3, L4, L5> | []) | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<any>;
|
package/dist/ops/create.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Item, LocKeyArray } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const create: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, v: Partial<Item<S, L1, L2, L3, L4, L5>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const create: <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>(v: Partial<Item<S, L1, L2, L3, L4, L5>>, locations: (LocKeyArray<L1, L2, L3, L4, L5> | []) | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V]>;
|
package/dist/ops/facet.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ComKey, Item, PriKey } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const facet: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const facet: <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>(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, facet: string, params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<any>;
|
package/dist/ops/find.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Item, LocKeyArray } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const find: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, finder: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const find: <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>(finder: string, params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> | undefined, locations: (LocKeyArray<L1, L2, L3, L4, L5> | []) | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
package/dist/ops/findOne.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Item, LocKeyArray } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const findOne: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const findOne: <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>(finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> | undefined, locations: (LocKeyArray<L1, L2, L3, L4, L5> | []) | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V]>;
|
package/dist/ops/get.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ComKey, Item, PriKey } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const get: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V | null]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const get: <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>(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V | null]>;
|
package/dist/ops/one.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Item, ItemQuery, LocKeyArray } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const one: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V | null]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const one: <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>(query: ItemQuery | undefined, locations: (LocKeyArray<L1, L2, L3, L4, L5> | []) | undefined, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V | null]>;
|
package/dist/ops/remove.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ComKey, Item, PriKey } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const remove: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<CacheMap<V, S, L1, L2, L3, L4, L5>>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const remove: <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>(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<CacheContext<V, S, L1, L2, L3, L4, L5>>;
|
package/dist/ops/reset.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Item } from "@fjell/core";
|
|
2
2
|
import { CacheMap } from "../CacheMap";
|
|
3
|
+
import { Options } from "../Options";
|
|
3
4
|
import { Coordinate } from "@fjell/registry";
|
|
4
|
-
export declare const reset: <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>(coordinate: Coordinate<S, L1, L2, L3, L4, L5>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]>;
|
|
5
|
+
export declare const reset: <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>(coordinate: Coordinate<S, L1, L2, L3, L4, L5>, options: Options<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]>;
|
package/dist/ops/retrieve.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ComKey, Item, PriKey } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const retrieve: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5> | null, V | null]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const retrieve: <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>(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5> | null, V | null]>;
|
package/dist/ops/set.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ComKey, Item, PriKey } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
export declare const set: <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>(
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const set: <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>(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, v: Item<S, L1, L2, L3, L4, L5>, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V]>;
|
package/dist/ops/update.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ComKey, Item, PriKey } from "@fjell/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const update: <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>, cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>, pkType: S, key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, v: Partial<Item<S, L1, L2, L3, L4, L5>>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
2
|
+
import { CacheContext } from "../CacheContext";
|
|
3
|
+
export declare const update: <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>(key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, v: Partial<Item<S, L1, L2, L3, L4, L5>>, context: CacheContext<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheContext<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for parsing and managing cache sizes
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Parse a size string and return the size in bytes
|
|
6
|
+
*
|
|
7
|
+
* @param sizeStr - Size string (e.g., '300', '3kb', '5MB', '2GiB')
|
|
8
|
+
* @returns Size in bytes
|
|
9
|
+
* @throws Error if the size string is invalid
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseSizeString(sizeStr: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* Format bytes as a human-readable string
|
|
14
|
+
*
|
|
15
|
+
* @param bytes - Size in bytes
|
|
16
|
+
* @param binary - Use binary units (1024) instead of decimal (1000)
|
|
17
|
+
* @returns Formatted size string
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatBytes(bytes: number, binary?: boolean): string;
|
|
20
|
+
/**
|
|
21
|
+
* Estimate the serialized size of a value in bytes
|
|
22
|
+
* This is an approximation for cache size calculations
|
|
23
|
+
*
|
|
24
|
+
* @param value - The value to estimate size for
|
|
25
|
+
* @returns Estimated size in bytes
|
|
26
|
+
*/
|
|
27
|
+
export declare function estimateValueSize(value: any): number;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a size configuration is valid
|
|
30
|
+
*
|
|
31
|
+
* @param config - Size configuration to validate
|
|
32
|
+
* @throws Error if configuration is invalid
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateSizeConfig(config: {
|
|
35
|
+
maxSizeBytes?: string;
|
|
36
|
+
maxItems?: number;
|
|
37
|
+
}): void;
|