@sebspark/promise-cache 1.1.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 +6 -18
- package/dist/index.d.ts +6 -18
- 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,10 +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
|
}
|
|
31
|
-
declare const createPersistor: (redis?:
|
|
32
|
-
url: string;
|
|
33
|
-
password?: string;
|
|
34
|
-
}) => Persistor;
|
|
25
|
+
declare const createPersistor: (redis?: RedisClientOptions) => Persistor;
|
|
35
26
|
|
|
36
27
|
declare class PromiseCache<U> {
|
|
37
28
|
persistor: Persistor;
|
|
@@ -45,10 +36,7 @@ declare class PromiseCache<U> {
|
|
|
45
36
|
constructor({ ttlInSeconds, caseSensitive, redis, }: {
|
|
46
37
|
ttlInSeconds?: number;
|
|
47
38
|
caseSensitive?: boolean;
|
|
48
|
-
redis?:
|
|
49
|
-
url: string;
|
|
50
|
-
password?: string;
|
|
51
|
-
};
|
|
39
|
+
redis?: RedisClientOptions;
|
|
52
40
|
});
|
|
53
41
|
/**
|
|
54
42
|
* Cache size.
|
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,10 +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
|
}
|
|
31
|
-
declare const createPersistor: (redis?:
|
|
32
|
-
url: string;
|
|
33
|
-
password?: string;
|
|
34
|
-
}) => Persistor;
|
|
25
|
+
declare const createPersistor: (redis?: RedisClientOptions) => Persistor;
|
|
35
26
|
|
|
36
27
|
declare class PromiseCache<U> {
|
|
37
28
|
persistor: Persistor;
|
|
@@ -45,10 +36,7 @@ declare class PromiseCache<U> {
|
|
|
45
36
|
constructor({ ttlInSeconds, caseSensitive, redis, }: {
|
|
46
37
|
ttlInSeconds?: number;
|
|
47
38
|
caseSensitive?: boolean;
|
|
48
|
-
redis?:
|
|
49
|
-
url: string;
|
|
50
|
-
password?: string;
|
|
51
|
-
};
|
|
39
|
+
redis?: RedisClientOptions;
|
|
52
40
|
});
|
|
53
41
|
/**
|
|
54
42
|
* Cache size.
|