keyv 6.0.0-beta.3 → 6.0.0-beta.4
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/LICENSE +0 -10
- package/README.md +203 -136
- package/dist/index.cjs +162 -82
- package/dist/index.d.cts +158 -61
- package/dist/index.d.mts +158 -61
- package/dist/index.mjs +162 -83
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -21,6 +21,20 @@ type KeyvStorageCapability = {
|
|
|
21
21
|
compatible: boolean;
|
|
22
22
|
store: "mapLike" | "keyvStorage" | "asyncMap" | "none";
|
|
23
23
|
methods: KeyvStorageMethods;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the adapter implements the v6 storage contract — it accepts an absolute
|
|
26
|
+
* `expires` timestamp (ms since epoch) on `set`/`setMany`. Adapters that omit this
|
|
27
|
+
* (legacy relative-`ttl` adapters) are wrapped by `KeyvBridgeAdapter`, which converts
|
|
28
|
+
* the absolute `expires` back to a relative ttl before delegating.
|
|
29
|
+
*
|
|
30
|
+
* Declaring `expires: true` is a two-way contract: the adapter is then used directly and
|
|
31
|
+
* must ENFORCE expiry on read. Keyv core does not filter expired entries by default
|
|
32
|
+
* (`checkExpired` is off), so the adapter is the expiry authority — `get`/`getMany`/`has`
|
|
33
|
+
* must return nothing for a key past its deadline, via a native mechanism (TTL index, key
|
|
34
|
+
* expiry, lease) and/or a client-side check. Validate with `@keyv/test-suite`'s
|
|
35
|
+
* `storageTtlTests`.
|
|
36
|
+
*/
|
|
37
|
+
expires?: boolean;
|
|
24
38
|
};
|
|
25
39
|
declare const keyvCompressionMethodNames: readonly ["compress", "decompress"];
|
|
26
40
|
type KeyvCompressionMethods = Record<(typeof keyvCompressionMethodNames)[number], KeyvStorageMethod>;
|
|
@@ -83,6 +97,21 @@ declare function detectKeyv(obj: unknown): KeyvCapability;
|
|
|
83
97
|
* ```
|
|
84
98
|
*/
|
|
85
99
|
declare function detectKeyvStorage(obj: unknown): KeyvStorageCapability;
|
|
100
|
+
/**
|
|
101
|
+
* Build the capability descriptor for a v6 storage adapter: the structurally detected
|
|
102
|
+
* methods plus `expires: true`, declaring that the adapter accepts an absolute `expires`
|
|
103
|
+
* timestamp on `set`/`setMany`. First-party adapters expose this from their `capabilities`
|
|
104
|
+
* getter so Keyv uses them directly instead of bridging.
|
|
105
|
+
* @param adapter - The storage adapter to describe (typically `this`).
|
|
106
|
+
* @returns A {@link KeyvStorageCapability} with `expires` set to `true`.
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* public get capabilities(): KeyvStorageCapability {
|
|
110
|
+
* return keyvStorageCapability(this);
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare function keyvStorageCapability(adapter: object): KeyvStorageCapability;
|
|
86
115
|
/**
|
|
87
116
|
* Detect whether an object implements the Keyv compression adapter interface
|
|
88
117
|
* @param obj - The object to check
|
|
@@ -493,7 +522,8 @@ declare enum KeyvHooks {
|
|
|
493
522
|
AFTER_DISCONNECT = "after:disconnect"
|
|
494
523
|
}
|
|
495
524
|
/**
|
|
496
|
-
* Represents a key-value entry with an optional TTL, used for
|
|
525
|
+
* Represents a key-value entry with an optional TTL, used for the public
|
|
526
|
+
* batch API `Keyv.setMany`.
|
|
497
527
|
*/
|
|
498
528
|
type KeyvEntry<Value = any> = {
|
|
499
529
|
/**
|
|
@@ -509,6 +539,17 @@ type KeyvEntry<Value = any> = {
|
|
|
509
539
|
*/
|
|
510
540
|
ttl?: number;
|
|
511
541
|
};
|
|
542
|
+
/**
|
|
543
|
+
* Represents a key-value entry at the storage-adapter boundary, carrying an
|
|
544
|
+
* absolute `expires` timestamp instead of a relative `ttl`. Keyv core computes
|
|
545
|
+
* `expires` once and passes these to a storage adapter's `setMany`, so adapters
|
|
546
|
+
* never derive expiry themselves.
|
|
547
|
+
*/
|
|
548
|
+
type KeyvStorageEntry<Value = any> = {
|
|
549
|
+
/** Key to set. */key: string; /** Value to set (already encoded by Keyv core). */
|
|
550
|
+
value: Value; /** Absolute expiry as Unix ms since epoch, or `undefined` for no expiry. */
|
|
551
|
+
expires?: number;
|
|
552
|
+
};
|
|
512
553
|
/**
|
|
513
554
|
* Configuration options for the Keyv constructor.
|
|
514
555
|
*/
|
|
@@ -602,11 +643,26 @@ type KeyvStorageGetResult<Value> = KeyvValue<Value> | string | undefined;
|
|
|
602
643
|
* Adapters handle the actual persistence of key-value pairs.
|
|
603
644
|
*/
|
|
604
645
|
type KeyvStorageAdapter = {
|
|
605
|
-
/** Optional namespace for key isolation. */namespace?: string | undefined;
|
|
646
|
+
/** Optional namespace for key isolation. */namespace?: string | undefined;
|
|
647
|
+
/**
|
|
648
|
+
* The adapter's capabilities. v6 adapters set `capabilities.expires = true` (e.g. via
|
|
649
|
+
* `keyvStorageCapability(this)`) to declare they accept an absolute `expires` timestamp
|
|
650
|
+
* on `set`/`setMany`. Full storage adapters that omit it are treated as legacy relative-`ttl`
|
|
651
|
+
* adapters and wrapped by `KeyvBridgeAdapter`, which converts `expires` back to a ttl.
|
|
652
|
+
*
|
|
653
|
+
* Declaring `expires: true` also obliges the adapter to enforce expiry on read: Keyv core
|
|
654
|
+
* does not filter expired entries by default, so `get`/`getMany`/`has` must not return a key
|
|
655
|
+
* past its deadline. See {@link KeyvStorageCapability.expires}.
|
|
656
|
+
*/
|
|
606
657
|
capabilities?: KeyvStorageCapability; /** Retrieves a value by key. */
|
|
607
|
-
get<Value>(key: string): Promise<KeyvStorageGetResult<Value>>;
|
|
608
|
-
|
|
609
|
-
|
|
658
|
+
get<Value>(key: string): Promise<KeyvStorageGetResult<Value>>;
|
|
659
|
+
/**
|
|
660
|
+
* Stores a value with a key and optional absolute expiry.
|
|
661
|
+
* @param expires Absolute expiry as Unix ms since epoch; `undefined` means no expiry.
|
|
662
|
+
* A value `<= Date.now()` is already expired and the adapter may delete/skip it.
|
|
663
|
+
*/
|
|
664
|
+
set(key: string, value: unknown, expires?: number): Promise<boolean>; /** Stores multiple entries at once, each with an absolute `expires` timestamp. */
|
|
665
|
+
setMany<Value>(values: KeyvStorageEntry<Value>[]): Promise<boolean[] | undefined>; /** Deletes a key from the store. */
|
|
610
666
|
delete(key: string): Promise<boolean>; /** Clears all entries from the store (respects namespace if set). */
|
|
611
667
|
clear(): Promise<void>; /** Checks if a key exists in the store. */
|
|
612
668
|
has(key: string): Promise<boolean>; /** Checks if multiple keys exist in the store. */
|
|
@@ -647,7 +703,8 @@ type KeyvBridgeAdapterOptions = {
|
|
|
647
703
|
* will be delegated to the store if present, otherwise fallback implementations are used.
|
|
648
704
|
*/
|
|
649
705
|
type KeyvBridgeStore = {
|
|
650
|
-
/** Store configuration/options (e.g. dialect, url) */opts?: any; /**
|
|
706
|
+
/** Store configuration/options (e.g. dialect, url) */opts?: any; /** Namespace the store scopes its keys under, when it manages its own namespacing. */
|
|
707
|
+
namespace?: string; /** Retrieves a value by key */
|
|
651
708
|
get(key: string): Promise<any>; /** Sets a value with a key and optional TTL */
|
|
652
709
|
set(key: string, value: any, ttl?: number): Promise<any>; /** Deletes a key from the store */
|
|
653
710
|
delete(key: string): Promise<boolean>; /** Clears all entries from the store */
|
|
@@ -690,6 +747,12 @@ declare class KeyvBridgeAdapter extends Hookified implements KeyvStorageAdapter
|
|
|
690
747
|
private _namespace?;
|
|
691
748
|
private _keySeparator;
|
|
692
749
|
private readonly _capabilities;
|
|
750
|
+
/**
|
|
751
|
+
* Whether the wrapped store manages its own namespace (exposes a `namespace` property).
|
|
752
|
+
* When true the bridge propagates its namespace to the store and does not prefix keys,
|
|
753
|
+
* so the store's native, namespace-scoped operations (notably `clear()`) are used directly.
|
|
754
|
+
*/
|
|
755
|
+
private readonly _storeHandlesNamespace;
|
|
693
756
|
/**
|
|
694
757
|
* Creates a new KeyvBridgeAdapter instance.
|
|
695
758
|
* @param store - The underlying promise-based store to bridge
|
|
@@ -705,7 +768,9 @@ declare class KeyvBridgeAdapter extends Hookified implements KeyvStorageAdapter
|
|
|
705
768
|
*/
|
|
706
769
|
set store(store: KeyvBridgeStore);
|
|
707
770
|
/**
|
|
708
|
-
* Gets the
|
|
771
|
+
* Gets the capabilities of the underlying store, with `expires: true` to declare that
|
|
772
|
+
* the bridge accepts an absolute `expires` timestamp (which it converts to a ttl for the
|
|
773
|
+
* wrapped legacy store).
|
|
709
774
|
*/
|
|
710
775
|
get capabilities(): KeyvStorageCapability;
|
|
711
776
|
/**
|
|
@@ -721,7 +786,8 @@ declare class KeyvBridgeAdapter extends Hookified implements KeyvStorageAdapter
|
|
|
721
786
|
*/
|
|
722
787
|
get namespace(): string | undefined;
|
|
723
788
|
/**
|
|
724
|
-
* Sets the namespace.
|
|
789
|
+
* Sets the namespace. When the wrapped store manages its own namespace, the value is
|
|
790
|
+
* propagated to it so its native scoped operations stay in sync.
|
|
725
791
|
*/
|
|
726
792
|
set namespace(namespace: string | undefined);
|
|
727
793
|
/**
|
|
@@ -752,19 +818,25 @@ declare class KeyvBridgeAdapter extends Hookified implements KeyvStorageAdapter
|
|
|
752
818
|
*/
|
|
753
819
|
getMany<T>(keys: string[]): Promise<Array<KeyvStorageGetResult<T | undefined>>>;
|
|
754
820
|
/**
|
|
755
|
-
* Stores a value in the store with an optional
|
|
821
|
+
* Stores a value in the store with an optional absolute expiry.
|
|
822
|
+
* The wrapped store's `set(key, value, ttl?)` expects a relative duration, so the absolute
|
|
823
|
+
* `expires` is converted to a remaining ttl (`undefined` when already expired or absent).
|
|
824
|
+
* The value is passed through unchanged — the bridge does not wrap it in an envelope — so
|
|
825
|
+
* expiry is enforced by the wrapped legacy store's own ttl handling. (The read-side
|
|
826
|
+
* {@link isDataExpired} check only fires when a caller stores a raw `{ value, expires }`
|
|
827
|
+
* object directly; when Keyv core drives the bridge the value arrives already encoded.)
|
|
756
828
|
* @param key - The key to store the value under
|
|
757
829
|
* @param value - The value to store
|
|
758
|
-
* @param
|
|
830
|
+
* @param expires - Optional absolute expiry as Unix ms since epoch
|
|
759
831
|
* @returns Always returns true indicating success
|
|
760
832
|
*/
|
|
761
|
-
set(key: string, value: any,
|
|
833
|
+
set(key: string, value: any, expires?: number): Promise<boolean>;
|
|
762
834
|
/**
|
|
763
835
|
* Stores multiple entries in the store at once.
|
|
764
836
|
* Delegates to the store's native setMany if available, otherwise loops over set.
|
|
765
|
-
* @param entries - Array of entries containing key, value, and optional
|
|
837
|
+
* @param entries - Array of entries containing key, value, and optional absolute `expires`
|
|
766
838
|
*/
|
|
767
|
-
setMany<Value>(entries:
|
|
839
|
+
setMany<Value>(entries: KeyvStorageEntry<Value>[]): Promise<boolean[] | undefined>;
|
|
768
840
|
/**
|
|
769
841
|
* Checks if a key exists in the store and is not expired.
|
|
770
842
|
* Delegates to the store's native has if available.
|
|
@@ -813,6 +885,17 @@ declare class KeyvBridgeAdapter extends Hookified implements KeyvStorageAdapter
|
|
|
813
885
|
//#endregion
|
|
814
886
|
//#region src/keyv.d.ts
|
|
815
887
|
declare class Keyv<GenericValue = any> extends Hookified {
|
|
888
|
+
/**
|
|
889
|
+
* Keyv Constructor
|
|
890
|
+
* @param {KeyvStorageAdapter | KeyvOptions | Map<any, any> | any} store to be provided or just the options
|
|
891
|
+
* @param {Omit<KeyvOptions, 'store'>} [options] if you provide the store you can then provide the Keyv Options
|
|
892
|
+
*/
|
|
893
|
+
constructor(store?: KeyvStorageAdapter | KeyvOptions | KeyvMapAny, options?: Omit<KeyvOptions, "store">);
|
|
894
|
+
/**
|
|
895
|
+
* Keyv Constructor
|
|
896
|
+
* @param {KeyvOptions} options to be provided
|
|
897
|
+
*/
|
|
898
|
+
constructor(options?: KeyvOptions);
|
|
816
899
|
/**
|
|
817
900
|
* Stats manager for tracking cache operation metrics (hits, misses, sets, deletes, errors).
|
|
818
901
|
* @default this is disabled.
|
|
@@ -851,17 +934,6 @@ declare class Keyv<GenericValue = any> extends Hookified {
|
|
|
851
934
|
* When true, Keyv checks expiry at its layer on get/getMany/has/hasMany.
|
|
852
935
|
*/
|
|
853
936
|
private _checkExpired;
|
|
854
|
-
/**
|
|
855
|
-
* Keyv Constructor
|
|
856
|
-
* @param {KeyvStorageAdapter | KeyvOptions | Map<any, any> | any} store to be provided or just the options
|
|
857
|
-
* @param {Omit<KeyvOptions, 'store'>} [options] if you provide the store you can then provide the Keyv Options
|
|
858
|
-
*/
|
|
859
|
-
constructor(store?: KeyvStorageAdapter | KeyvOptions | KeyvMapAny, options?: Omit<KeyvOptions, "store">);
|
|
860
|
-
/**
|
|
861
|
-
* Keyv Constructor
|
|
862
|
-
* @param {KeyvOptions} options to be provided
|
|
863
|
-
*/
|
|
864
|
-
constructor(options?: KeyvOptions);
|
|
865
937
|
/**
|
|
866
938
|
* Get the current storage adapter.
|
|
867
939
|
* @returns {KeyvStorageAdapter} The current storage adapter.
|
|
@@ -952,11 +1024,6 @@ declare class Keyv<GenericValue = any> extends Hookified {
|
|
|
952
1024
|
* @returns {KeyvStats} The current stats.
|
|
953
1025
|
*/
|
|
954
1026
|
get stats(): KeyvStats;
|
|
955
|
-
/**
|
|
956
|
-
* When true, Keyv checks expiry at its layer on get/getMany/has/hasMany.
|
|
957
|
-
* When false (default), trusts the storage adapter.
|
|
958
|
-
*/
|
|
959
|
-
get checkExpired(): boolean;
|
|
960
1027
|
/**
|
|
961
1028
|
* Set the stats. When setting a new instance it will unsubscribe the old listeners
|
|
962
1029
|
* and subscribe the new instance.
|
|
@@ -964,11 +1031,21 @@ declare class Keyv<GenericValue = any> extends Hookified {
|
|
|
964
1031
|
*/
|
|
965
1032
|
set stats(stats: KeyvStats);
|
|
966
1033
|
/**
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
|
|
971
|
-
|
|
1034
|
+
* Get whether Keyv checks expiry at its own layer on get/getMany/has/hasMany.
|
|
1035
|
+
* When false (default), it trusts the storage adapter to handle expiry.
|
|
1036
|
+
* @returns {boolean} `true` if Keyv checks expiry at its layer.
|
|
1037
|
+
*/
|
|
1038
|
+
get checkExpired(): boolean;
|
|
1039
|
+
/**
|
|
1040
|
+
* Resolves a store to a fully-compliant KeyvStorageAdapter:
|
|
1041
|
+
* 1. If the store declares the v6 `capabilities.expires` contract, use it directly (this takes
|
|
1042
|
+
* precedence over structural detection, so a full adapter whose async methods aren't written
|
|
1043
|
+
* with the `async` keyword is not mis-bridged).
|
|
1044
|
+
* 2. If the store implements the full async storage interface (but doesn't declare `expires`),
|
|
1045
|
+
* treat it as a legacy relative-`ttl` adapter and wrap it in KeyvBridgeAdapter.
|
|
1046
|
+
* 3. If the store is map-like (synchronous get/set/delete/has), wrap it in KeyvMemoryAdapter.
|
|
1047
|
+
* 4. If the store has async get/set/delete/clear, wrap it in KeyvBridgeAdapter.
|
|
1048
|
+
* 5. Otherwise, emit an error and fall back to a default in-memory KeyvMemoryAdapter.
|
|
972
1049
|
*
|
|
973
1050
|
* NOTE: this is used for internal but provided public for custom adapter testing
|
|
974
1051
|
* @param {unknown} store The store to resolve.
|
|
@@ -987,14 +1064,29 @@ declare class Keyv<GenericValue = any> extends Hookified {
|
|
|
987
1064
|
*/
|
|
988
1065
|
setTtl(ttl?: number): void;
|
|
989
1066
|
/**
|
|
990
|
-
* Get the
|
|
1067
|
+
* Get the value of a key. If an array of keys is passed in it will return an array of values
|
|
1068
|
+
* delegating to {@link getMany}.
|
|
991
1069
|
* @param {string | string[]} key passing in a single key or multiple as an array
|
|
1070
|
+
* @returns {Promise<Value | undefined | Array<Value | undefined>>} the value of the key, or
|
|
1071
|
+
* `undefined` if the key does not exist or is expired. When an array of keys is passed in it
|
|
1072
|
+
* returns an array of values in the same order (with `undefined` for missing keys).
|
|
992
1073
|
*/
|
|
993
1074
|
get<Value = GenericValue>(key: string): Promise<Value | undefined>;
|
|
994
1075
|
get<Value = GenericValue>(key: string[]): Promise<Array<Value | undefined>>;
|
|
995
1076
|
/**
|
|
996
|
-
*
|
|
997
|
-
*
|
|
1077
|
+
* Reads many keys from the store, preferring its native `getMany` and falling back to parallel
|
|
1078
|
+
* single `get`s when an adapter does not implement it. A directly-used v6 adapter is not
|
|
1079
|
+
* structurally required to provide `getMany` (the bridge and memory adapters always do), so
|
|
1080
|
+
* this keeps `getMany`/`getManyRaw` working regardless of the resolved adapter.
|
|
1081
|
+
* @param keys - the keys to read
|
|
1082
|
+
* @returns the raw store results in the same order as `keys`
|
|
1083
|
+
*/
|
|
1084
|
+
private storeGetMany;
|
|
1085
|
+
/**
|
|
1086
|
+
* Get many values for an array of keys.
|
|
1087
|
+
* @param {string[]} keys the keys to get
|
|
1088
|
+
* @returns {Promise<Array<Value | undefined>>} an array of values in the same order as the
|
|
1089
|
+
* keys, with `undefined` for keys that do not exist or are expired.
|
|
998
1090
|
*/
|
|
999
1091
|
getMany<Value = GenericValue>(keys: string[]): Promise<Array<Value | undefined>>;
|
|
1000
1092
|
/**
|
|
@@ -1012,16 +1104,16 @@ declare class Keyv<GenericValue = any> extends Hookified {
|
|
|
1012
1104
|
getManyRaw<Value = GenericValue>(keys: string[]): Promise<Array<KeyvStorageGetResult<Value>>>;
|
|
1013
1105
|
/**
|
|
1014
1106
|
* Set an item to the store
|
|
1015
|
-
* @param {string
|
|
1107
|
+
* @param {string} key the key to use
|
|
1016
1108
|
* @param {Value} value the value of the key
|
|
1017
|
-
* @param {number} [ttl] time to live in milliseconds
|
|
1018
|
-
* @returns {boolean} if it
|
|
1109
|
+
* @param {number} [ttl] time to live in milliseconds. Overrides the instance-level `ttl`.
|
|
1110
|
+
* @returns {Promise<boolean>} `true` if it was set successfully, `false` on failure.
|
|
1019
1111
|
*/
|
|
1020
1112
|
set<Value = GenericValue>(key: string, value: Value, ttl?: number): Promise<boolean>;
|
|
1021
1113
|
/**
|
|
1022
1114
|
* Set many items to the store
|
|
1023
1115
|
* @param {Array<KeyvEntry<Value>>} entries the entries to set
|
|
1024
|
-
* @returns {boolean[]}
|
|
1116
|
+
* @returns {Promise<boolean[]>} an array of booleans, one per entry: `true` if set successfully, `false` on failure.
|
|
1025
1117
|
*/
|
|
1026
1118
|
setMany<Value = GenericValue>(entries: KeyvEntry<Value>[]): Promise<boolean[]>;
|
|
1027
1119
|
/**
|
|
@@ -1031,7 +1123,7 @@ declare class Keyv<GenericValue = any> extends Hookified {
|
|
|
1031
1123
|
* The store-level TTL is derived automatically from `value.expires`.
|
|
1032
1124
|
* @param {string} key the key to set
|
|
1033
1125
|
* @param {KeyvValue<Value>} value the raw value envelope to store
|
|
1034
|
-
* @returns {boolean} if it
|
|
1126
|
+
* @returns {Promise<boolean>} `true` if it was set successfully, `false` on failure.
|
|
1035
1127
|
*/
|
|
1036
1128
|
setRaw<Value = GenericValue>(key: string, value: KeyvValue<Value>): Promise<boolean>;
|
|
1037
1129
|
/**
|
|
@@ -1039,43 +1131,47 @@ declare class Keyv<GenericValue = any> extends Hookified {
|
|
|
1039
1131
|
* Each entry's value should be a KeyvValue object with { value, expires? }. If you need TTL-based expiration,
|
|
1040
1132
|
* set `expires` on each value directly. The store-level TTL is derived automatically from `value.expires`.
|
|
1041
1133
|
* @param {KeyvEntry<KeyvValue<Value>>[]} entries the raw entries to set
|
|
1042
|
-
* @returns {boolean[]}
|
|
1134
|
+
* @returns {Promise<boolean[]>} an array of booleans, one per entry: `true` if set successfully, `false` on failure.
|
|
1043
1135
|
*/
|
|
1044
1136
|
setManyRaw<Value = GenericValue>(entries: KeyvEntry<KeyvValue<Value>>[]): Promise<boolean[]>;
|
|
1045
1137
|
/**
|
|
1046
|
-
* Delete an
|
|
1138
|
+
* Delete an entry. If an array of keys is passed in it will delete many entries
|
|
1139
|
+
* delegating to {@link deleteMany}.
|
|
1047
1140
|
* @param {string} key the key to be deleted
|
|
1048
|
-
* @returns {boolean}
|
|
1141
|
+
* @returns {Promise<boolean>} `true` if the item was deleted, `false` if there was an error.
|
|
1049
1142
|
*/
|
|
1050
1143
|
delete(key: string): Promise<boolean>;
|
|
1051
1144
|
/**
|
|
1052
|
-
* Delete multiple
|
|
1145
|
+
* Delete multiple entries
|
|
1053
1146
|
* @param {string[]} keys the keys to be deleted
|
|
1054
|
-
* @returns {boolean[]}
|
|
1147
|
+
* @returns {Promise<boolean[]>} an array of booleans indicating success for each key.
|
|
1055
1148
|
*/
|
|
1056
1149
|
delete(keys: string[]): Promise<boolean[]>;
|
|
1057
1150
|
/**
|
|
1058
1151
|
* Delete many items from the store
|
|
1059
1152
|
* @param {string[]} keys the keys to be deleted
|
|
1060
|
-
* @returns {boolean[]} array of booleans indicating success for each key
|
|
1153
|
+
* @returns {Promise<boolean[]>} an array of booleans indicating success for each key.
|
|
1061
1154
|
*/
|
|
1062
1155
|
deleteMany(keys: string[]): Promise<boolean[]>;
|
|
1063
1156
|
/**
|
|
1064
|
-
*
|
|
1065
|
-
* @
|
|
1066
|
-
* @
|
|
1157
|
+
* Check if a key exists. If an array of keys is passed in it will check many keys
|
|
1158
|
+
* delegating to {@link hasMany}.
|
|
1159
|
+
* @param {string | string[]} key the key (or keys) to check
|
|
1160
|
+
* @returns {Promise<boolean | boolean[]>} `true` if the key exists, `false` if not. When an
|
|
1161
|
+
* array of keys is passed in it returns an array of booleans in the same order.
|
|
1067
1162
|
*/
|
|
1068
1163
|
has(key: string[]): Promise<boolean[]>;
|
|
1069
1164
|
has(key: string): Promise<boolean>;
|
|
1070
1165
|
/**
|
|
1071
1166
|
* Check if many keys exist
|
|
1072
1167
|
* @param {string[]} keys the keys to check
|
|
1073
|
-
* @returns {boolean[]}
|
|
1168
|
+
* @returns {Promise<boolean[]>} an array of booleans in the same order as the keys, `true` if the key exists.
|
|
1074
1169
|
*/
|
|
1075
1170
|
hasMany(keys: string[]): Promise<boolean[]>;
|
|
1076
1171
|
/**
|
|
1077
|
-
* Clear the store
|
|
1078
|
-
*
|
|
1172
|
+
* Clear the store. If a namespace is set only entries in that namespace are removed.
|
|
1173
|
+
* Emits a `clear` event.
|
|
1174
|
+
* @returns {Promise<void>} resolves once the entries have been cleared.
|
|
1079
1175
|
*/
|
|
1080
1176
|
clear(): Promise<void>;
|
|
1081
1177
|
/**
|
|
@@ -1202,7 +1298,8 @@ declare class KeyvMemoryAdapter extends Hookified implements KeyvStorageAdapter
|
|
|
1202
1298
|
*/
|
|
1203
1299
|
constructor(store: KeyvMapType, options?: KeyvMemoryAdapterOptions);
|
|
1204
1300
|
/**
|
|
1205
|
-
* Gets the
|
|
1301
|
+
* Gets the capabilities of the underlying store, with `expires: true` to declare that
|
|
1302
|
+
* this adapter accepts an absolute `expires` timestamp (the v6 storage contract).
|
|
1206
1303
|
*/
|
|
1207
1304
|
get capabilities(): KeyvStorageCapability;
|
|
1208
1305
|
/**
|
|
@@ -1256,18 +1353,18 @@ declare class KeyvMemoryAdapter extends Hookified implements KeyvStorageAdapter
|
|
|
1256
1353
|
*/
|
|
1257
1354
|
get<T>(key: string): Promise<KeyvStorageGetResult<T>>;
|
|
1258
1355
|
/**
|
|
1259
|
-
* Stores a value in the store with an optional
|
|
1356
|
+
* Stores a value in the store with an optional absolute expiry.
|
|
1260
1357
|
* @param key - The key to store the value under
|
|
1261
1358
|
* @param value - The value to store
|
|
1262
|
-
* @param
|
|
1359
|
+
* @param expires - Optional absolute expiry as Unix ms since epoch
|
|
1263
1360
|
* @returns Always returns true indicating success
|
|
1264
1361
|
*/
|
|
1265
|
-
set(key: string, value: any,
|
|
1362
|
+
set(key: string, value: any, expires?: number): Promise<boolean>;
|
|
1266
1363
|
/**
|
|
1267
1364
|
* Stores multiple entries in the store at once.
|
|
1268
|
-
* @param entries - Array of entries containing key, value, and optional
|
|
1365
|
+
* @param entries - Array of entries containing key, value, and optional absolute `expires`
|
|
1269
1366
|
*/
|
|
1270
|
-
setMany<Value>(entries:
|
|
1367
|
+
setMany<Value>(entries: KeyvStorageEntry<Value>[]): Promise<boolean[] | undefined>;
|
|
1271
1368
|
/**
|
|
1272
1369
|
* Deletes a value from the store by key.
|
|
1273
1370
|
* @param key - The key to delete
|
|
@@ -1348,4 +1445,4 @@ declare class KeyvJsonSerializer implements KeyvSerializationAdapter {
|
|
|
1348
1445
|
}
|
|
1349
1446
|
declare const jsonSerializer: KeyvJsonSerializer;
|
|
1350
1447
|
//#endregion
|
|
1351
|
-
export { type DeserializedData, Keyv, Keyv as default, KeyvBridgeAdapter, type KeyvBridgeAdapterOptions, type KeyvBridgeStore, type KeyvCapability, type KeyvCompression, type KeyvCompressionAdapter, type KeyvCompressionCapability, type KeyvCompressionMethods, type KeyvEncryptionAdapter, type KeyvEncryptionCapability, type KeyvEncryptionMethods, type KeyvEntry, KeyvEvents, KeyvHooks, KeyvJsonSerializer, type KeyvMapAny, type KeyvMapType, KeyvMemoryAdapter, type KeyvMemoryAdapterOptions, type KeyvMethods, type KeyvOptions, type KeyvProperties, KeyvSanitize, type KeyvSanitizeAdapter, type KeyvSanitizeOptions, type KeyvSanitizePatterns, type KeyvSerializationAdapter, type KeyvSerializationCapability, type KeyvSerializationMethods, KeyvStats, type KeyvStatsOptions, type KeyvStorageAdapter, type KeyvStorageCapability, type KeyvStorageGetResult, type KeyvStorageMethod, type KeyvStorageMethods, type KeyvStoreAdapter, type KeyvTelemetryEvent, type KeyvValue, type MethodType, createKeyv, detectKeyv, detectKeyvCompression, detectKeyvEncryption, detectKeyvSerialization, detectKeyvStorage, jsonSerializer };
|
|
1448
|
+
export { type DeserializedData, Keyv, Keyv as default, KeyvBridgeAdapter, type KeyvBridgeAdapterOptions, type KeyvBridgeStore, type KeyvCapability, type KeyvCompression, type KeyvCompressionAdapter, type KeyvCompressionCapability, type KeyvCompressionMethods, type KeyvEncryptionAdapter, type KeyvEncryptionCapability, type KeyvEncryptionMethods, type KeyvEntry, KeyvEvents, KeyvHooks, KeyvJsonSerializer, type KeyvMapAny, type KeyvMapType, KeyvMemoryAdapter, type KeyvMemoryAdapterOptions, type KeyvMethods, type KeyvOptions, type KeyvProperties, KeyvSanitize, type KeyvSanitizeAdapter, type KeyvSanitizeOptions, type KeyvSanitizePatterns, type KeyvSerializationAdapter, type KeyvSerializationCapability, type KeyvSerializationMethods, KeyvStats, type KeyvStatsOptions, type KeyvStorageAdapter, type KeyvStorageCapability, type KeyvStorageEntry, type KeyvStorageGetResult, type KeyvStorageMethod, type KeyvStorageMethods, type KeyvStoreAdapter, type KeyvTelemetryEvent, type KeyvValue, type MethodType, createKeyv, detectKeyv, detectKeyvCompression, detectKeyvEncryption, detectKeyvSerialization, detectKeyvStorage, jsonSerializer, keyvStorageCapability };
|