-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
51 lines (43 loc) · 1.34 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
interface MapLike<K, V> {
get(key: K): Promise<any>;
set(key: K, value: V): Promise<boolean>;
delete(key: K): Promise<boolean>;
clear(): Promise<void>;
}
interface iOptions {
/** Namespace for the current instance. */
prefix?: string;
/** A custom serialization function. */
serialize?: (data: any) => string;
/** A custom deserialization function. */
deserialize?: (data: string) => any;
/** The storage adapter instance to be used by MaybeStore. */
store?: MapLike<string, any>;
/** Default TTL. Can be overridden by specififying a TTL on `.set()`. */
ttl?: number;
}
declare class MaybeStore {
/**
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
*/
constructor(opts?: iOptions);
/** Returns the namespace of a key */
_getKeyPrefix(key: string): string;
/** Returns the value. */
get(key: string): Promise<any>;
/**
* Set a value.
*
* By default keys are persistent. You can set an expiry TTL in milliseconds.
*/
set(key: string, value: any, ttl?: number): Promise<boolean>;
/**
* Deletes an entry.
*
* Returns `true` if the key existed, `false` if not.
*/
delete(key: string): Promise<boolean>;
/** Delete all entries in the current namespace. */
clear(): Promise<void>;
}
export = MaybeStore;