@sebspark/promise-cache 1.0.0 → 1.2.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/dist/index.d.mts +7 -15
- package/dist/index.d.ts +7 -15
- package/dist/index.js +6 -2
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createClient } from 'redis';
|
|
1
|
+
import { createClient, RedisClientOptions } from 'redis';
|
|
2
2
|
|
|
3
3
|
type GetType<T> = {
|
|
4
4
|
value: T;
|
|
@@ -12,15 +12,9 @@ type SetParams<T> = {
|
|
|
12
12
|
};
|
|
13
13
|
declare class Persistor {
|
|
14
14
|
client: ReturnType<typeof createClient> | null;
|
|
15
|
-
status
|
|
16
|
-
redis
|
|
17
|
-
|
|
18
|
-
password?: string;
|
|
19
|
-
} | undefined;
|
|
20
|
-
constructor(redis?: {
|
|
21
|
-
url: string;
|
|
22
|
-
password?: string;
|
|
23
|
-
});
|
|
15
|
+
private status;
|
|
16
|
+
private readonly redis?;
|
|
17
|
+
constructor(redis?: RedisClientOptions);
|
|
24
18
|
connect(onError?: (message: string) => void, onConnect?: (message: string) => void): Promise<void>;
|
|
25
19
|
size(): Promise<number>;
|
|
26
20
|
get<T>(key: string): Promise<GetType<T> | null>;
|
|
@@ -28,6 +22,7 @@ declare class Persistor {
|
|
|
28
22
|
set<T>(key: string, { value, timestamp, ttl }: SetParams<T>): Promise<void>;
|
|
29
23
|
delete(key: string): Promise<void>;
|
|
30
24
|
}
|
|
25
|
+
declare const createPersistor: (redis?: RedisClientOptions) => Persistor;
|
|
31
26
|
|
|
32
27
|
declare class PromiseCache<U> {
|
|
33
28
|
persistor: Persistor;
|
|
@@ -41,10 +36,7 @@ declare class PromiseCache<U> {
|
|
|
41
36
|
constructor({ ttlInSeconds, caseSensitive, redis, }: {
|
|
42
37
|
ttlInSeconds?: number;
|
|
43
38
|
caseSensitive?: boolean;
|
|
44
|
-
redis?:
|
|
45
|
-
url: string;
|
|
46
|
-
password?: string;
|
|
47
|
-
};
|
|
39
|
+
redis?: RedisClientOptions;
|
|
48
40
|
});
|
|
49
41
|
/**
|
|
50
42
|
* Cache size.
|
|
@@ -87,4 +79,4 @@ declare class LocalStorage {
|
|
|
87
79
|
}
|
|
88
80
|
declare const createLocalMemoryClient: () => LocalStorage;
|
|
89
81
|
|
|
90
|
-
export { LocalStorage, PromiseCache, createLocalMemoryClient };
|
|
82
|
+
export { LocalStorage, Persistor, PromiseCache, createLocalMemoryClient, createPersistor };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createClient } from 'redis';
|
|
1
|
+
import { createClient, RedisClientOptions } from 'redis';
|
|
2
2
|
|
|
3
3
|
type GetType<T> = {
|
|
4
4
|
value: T;
|
|
@@ -12,15 +12,9 @@ type SetParams<T> = {
|
|
|
12
12
|
};
|
|
13
13
|
declare class Persistor {
|
|
14
14
|
client: ReturnType<typeof createClient> | null;
|
|
15
|
-
status
|
|
16
|
-
redis
|
|
17
|
-
|
|
18
|
-
password?: string;
|
|
19
|
-
} | undefined;
|
|
20
|
-
constructor(redis?: {
|
|
21
|
-
url: string;
|
|
22
|
-
password?: string;
|
|
23
|
-
});
|
|
15
|
+
private status;
|
|
16
|
+
private readonly redis?;
|
|
17
|
+
constructor(redis?: RedisClientOptions);
|
|
24
18
|
connect(onError?: (message: string) => void, onConnect?: (message: string) => void): Promise<void>;
|
|
25
19
|
size(): Promise<number>;
|
|
26
20
|
get<T>(key: string): Promise<GetType<T> | null>;
|
|
@@ -28,6 +22,7 @@ declare class Persistor {
|
|
|
28
22
|
set<T>(key: string, { value, timestamp, ttl }: SetParams<T>): Promise<void>;
|
|
29
23
|
delete(key: string): Promise<void>;
|
|
30
24
|
}
|
|
25
|
+
declare const createPersistor: (redis?: RedisClientOptions) => Persistor;
|
|
31
26
|
|
|
32
27
|
declare class PromiseCache<U> {
|
|
33
28
|
persistor: Persistor;
|
|
@@ -41,10 +36,7 @@ declare class PromiseCache<U> {
|
|
|
41
36
|
constructor({ ttlInSeconds, caseSensitive, redis, }: {
|
|
42
37
|
ttlInSeconds?: number;
|
|
43
38
|
caseSensitive?: boolean;
|
|
44
|
-
redis?:
|
|
45
|
-
url: string;
|
|
46
|
-
password?: string;
|
|
47
|
-
};
|
|
39
|
+
redis?: RedisClientOptions;
|
|
48
40
|
});
|
|
49
41
|
/**
|
|
50
42
|
* Cache size.
|
|
@@ -87,4 +79,4 @@ declare class LocalStorage {
|
|
|
87
79
|
}
|
|
88
80
|
declare const createLocalMemoryClient: () => LocalStorage;
|
|
89
81
|
|
|
90
|
-
export { LocalStorage, PromiseCache, createLocalMemoryClient };
|
|
82
|
+
export { LocalStorage, Persistor, PromiseCache, createLocalMemoryClient, createPersistor };
|
package/dist/index.js
CHANGED
|
@@ -21,8 +21,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
LocalStorage: () => LocalStorage,
|
|
24
|
+
Persistor: () => Persistor,
|
|
24
25
|
PromiseCache: () => PromiseCache,
|
|
25
|
-
createLocalMemoryClient: () => createLocalMemoryClient
|
|
26
|
+
createLocalMemoryClient: () => createLocalMemoryClient,
|
|
27
|
+
createPersistor: () => createPersistor
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(src_exports);
|
|
28
30
|
|
|
@@ -253,6 +255,8 @@ var PromiseCache = class {
|
|
|
253
255
|
// Annotate the CommonJS export names for ESM import in node:
|
|
254
256
|
0 && (module.exports = {
|
|
255
257
|
LocalStorage,
|
|
258
|
+
Persistor,
|
|
256
259
|
PromiseCache,
|
|
257
|
-
createLocalMemoryClient
|
|
260
|
+
createLocalMemoryClient,
|
|
261
|
+
createPersistor
|
|
258
262
|
});
|
package/dist/index.mjs
CHANGED