@candlerip/shared 0.0.130 → 0.0.131
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/redis/workers/index.js +9 -8
- package/cache/redis/workers/type.d.ts +8 -8
- package/package.json +1 -1
- /package/cache/redis/workers/{compose-redis-get-data → compose-get-redis-data}/index.d.ts +0 -0
- /package/cache/redis/workers/{compose-redis-get-data → compose-get-redis-data}/index.js +0 -0
- /package/cache/redis/workers/{compose-redis-get-data → compose-get-redis-data}/type.d.ts +0 -0
- /package/cache/redis/workers/{compose-redis-get-data → compose-get-redis-data}/type.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CustomErrorWorker } from '../../../common/index.js';
|
|
2
2
|
import { createClient } from 'redis';
|
|
3
|
-
import { composeGetRedisData } from './compose-redis-
|
|
3
|
+
import { composeGetRedisData } from './compose-get-redis-data/index.js';
|
|
4
4
|
export const CacheWorker = (environmentMode, url, password, options) => {
|
|
5
5
|
const _isEnabled = Boolean(options?.isEnabled);
|
|
6
6
|
const customErrorWorker = CustomErrorWorker();
|
|
@@ -38,9 +38,10 @@ export const CacheWorker = (environmentMode, url, password, options) => {
|
|
|
38
38
|
data: _client,
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
const
|
|
41
|
+
const get = async (props) => {
|
|
42
|
+
const { cacheKey } = props;
|
|
42
43
|
const { composeCustomError } = CustomErrorWorker({ info: props });
|
|
43
|
-
const {
|
|
44
|
+
const { objKeys, pathKeys } = composeGetRedisData(props);
|
|
44
45
|
const { data: client, customError } = _getClient();
|
|
45
46
|
if (customError) {
|
|
46
47
|
return { customError };
|
|
@@ -79,7 +80,7 @@ export const CacheWorker = (environmentMode, url, password, options) => {
|
|
|
79
80
|
data: normalizedData,
|
|
80
81
|
};
|
|
81
82
|
};
|
|
82
|
-
const
|
|
83
|
+
const gets = async (props) => {
|
|
83
84
|
const { composeCustomError } = CustomErrorWorker({ info: { props } });
|
|
84
85
|
const getRedisData = props.map((it) => composeGetRedisData(it));
|
|
85
86
|
const { data: client, customError } = _getClient();
|
|
@@ -123,7 +124,7 @@ export const CacheWorker = (environmentMode, url, password, options) => {
|
|
|
123
124
|
data: normalizedData,
|
|
124
125
|
};
|
|
125
126
|
};
|
|
126
|
-
const
|
|
127
|
+
const set = async (key, data) => {
|
|
127
128
|
const { composeCustomError } = CustomErrorWorker({ info: { key } });
|
|
128
129
|
const { data: client, customError } = _getClient();
|
|
129
130
|
if (customError) {
|
|
@@ -142,8 +143,8 @@ export const CacheWorker = (environmentMode, url, password, options) => {
|
|
|
142
143
|
};
|
|
143
144
|
};
|
|
144
145
|
return {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
get,
|
|
147
|
+
gets,
|
|
148
|
+
set,
|
|
148
149
|
};
|
|
149
150
|
};
|
|
@@ -4,23 +4,23 @@ import { createClient } from 'redis';
|
|
|
4
4
|
export type TCacheWorker = (environmentMode: EnvironmentMode, url: string, password: string, options?: {
|
|
5
5
|
isEnabled?: boolean;
|
|
6
6
|
}) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
get: Get;
|
|
8
|
+
gets: Gets;
|
|
9
|
+
set: Set;
|
|
10
10
|
};
|
|
11
11
|
export type GetClient = () => TCustomError<ReturnType<typeof createClient>>;
|
|
12
|
-
export type
|
|
13
|
-
export type
|
|
14
|
-
export type
|
|
12
|
+
export type Set = <T extends keyof Cache>(key: T, data: Cache[T]) => Promise<TCustomError<null>>;
|
|
13
|
+
export type Get = <T extends CacheData = never, C extends CacheKey = CacheKey>(props: GetProps<C>) => Promise<TCustomError<T>>;
|
|
14
|
+
export type GetProps<C extends CacheKey> = C extends CandleLightingProfilesCacheKey ? {
|
|
15
15
|
cacheKey: C;
|
|
16
16
|
objKey?: ObjKey;
|
|
17
17
|
} : {
|
|
18
18
|
cacheKey: C;
|
|
19
19
|
objKeys?: string[];
|
|
20
20
|
};
|
|
21
|
-
export type
|
|
21
|
+
export type Gets = <T extends {
|
|
22
22
|
[key in CacheKey]?: CacheData;
|
|
23
|
-
} = never, C extends CacheKey = CacheKey>(props:
|
|
23
|
+
} = never, C extends CacheKey = CacheKey>(props: GetProps<C>[]) => Promise<TCustomError<T>>;
|
|
24
24
|
export type ObjKeys = string[];
|
|
25
25
|
export type ObjKey = {
|
|
26
26
|
code: number;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|