@common-stack/store-redis 8.3.1-alpha.0 → 8.3.1-alpha.1
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/lib/core/ioredis.d.ts +3 -2
- package/lib/core/ioredis.js +7 -1
- package/lib/core/ioredis.js.map +1 -1
- package/lib/core/upstash-redis.d.ts +4 -2
- package/lib/core/upstash-redis.js +19 -1
- package/lib/core/upstash-redis.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/module.d.ts +4 -0
- package/lib/module.js +6 -2
- package/lib/module.js.map +1 -1
- package/lib/{interfaces/redis.d.ts → templates/repositories/RedisClient.ts.template} +1 -3
- package/package.json +6 -5
- package/lib/interfaces/index.d.ts +0 -1
- /package/lib/templates/repositories/{IRedisKeyBuilder.ts.template → RedisKeyBuilder.ts.template} +0 -0
package/lib/core/ioredis.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
|
-
import { IRedisClient } from 'common/server';
|
|
2
|
+
import type { IRedisClient } from 'common/server';
|
|
3
3
|
export declare class IORedisClient implements IRedisClient {
|
|
4
4
|
private redis;
|
|
5
5
|
constructor(config: {
|
|
6
6
|
url: string;
|
|
7
7
|
});
|
|
8
|
-
get(key: string): Promise<any | null>;
|
|
8
|
+
get(key: string, callback?: (...args: any[]) => void): Promise<any | null>;
|
|
9
9
|
set(key: string, value: string, options?: {
|
|
10
10
|
ex?: number;
|
|
11
11
|
}): Promise<string>;
|
|
12
12
|
delMulti(keys: string[]): Promise<any>;
|
|
13
13
|
del(key: string): Promise<number>;
|
|
14
14
|
on(event: string, cb: (...args: any[]) => void): Redis;
|
|
15
|
+
once(event: string, cb: (...args: any[]) => void): Redis;
|
|
15
16
|
}
|
package/lib/core/ioredis.js
CHANGED
|
@@ -3,7 +3,10 @@ import Redis from'ioredis';class IORedisClient {
|
|
|
3
3
|
constructor(config) {
|
|
4
4
|
this.redis = new Redis(config.url);
|
|
5
5
|
}
|
|
6
|
-
async get(key) {
|
|
6
|
+
async get(key, callback) {
|
|
7
|
+
if (callback) {
|
|
8
|
+
return this.redis.get(key, callback);
|
|
9
|
+
}
|
|
7
10
|
const data = await this.redis.get(key);
|
|
8
11
|
return data;
|
|
9
12
|
}
|
|
@@ -24,4 +27,7 @@ import Redis from'ioredis';class IORedisClient {
|
|
|
24
27
|
on(event, cb) {
|
|
25
28
|
return this.redis.on(event, cb);
|
|
26
29
|
}
|
|
30
|
+
once(event, cb) {
|
|
31
|
+
return this.redis.once(event, cb);
|
|
32
|
+
}
|
|
27
33
|
}export{IORedisClient};//# sourceMappingURL=ioredis.js.map
|
package/lib/core/ioredis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ioredis.js","sources":["../../src/core/ioredis.ts"],"sourcesContent":["import Redis from 'ioredis';\nimport { IRedisClient } from 'common/server';\n\nexport class IORedisClient implements IRedisClient {\n private redis: Redis;\n\n constructor(config: { url: string }) {\n this.redis = new Redis(config.url);\n }\n\n async get(key: string): Promise<any | null> {\n const data = await this.redis.get(key);\n return data;\n }\n\n async set(key: string, value: string, options?: { ex?: number }): Promise<string> {\n if (options?.ex) {\n return await this.redis.set(key, value, 'EX', options?.ex);\n } else {\n return await this.redis.set(key, value);\n }\n }\n\n async delMulti(keys: string[]): Promise<any> {\n return await this.redis.del(keys);\n }\n\n async del(key: string): Promise<number> {\n return await this.redis.del(key);\n }\n\n on(event: string, cb: (...args: any[]) => void) {\n return this.redis.on(event, cb);\n }\n}\n"],"names":[],"mappings":"iCAGa,aAAa,CAAA;AACd,IAAA,KAAK,CAAQ;AAErB,IAAA,WAAA,CAAY,MAAuB,EAAA;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACtC;
|
|
1
|
+
{"version":3,"file":"ioredis.js","sources":["../../src/core/ioredis.ts"],"sourcesContent":["import Redis from 'ioredis';\nimport type { IRedisClient } from 'common/server';\n\nexport class IORedisClient implements IRedisClient {\n private redis: Redis;\n\n constructor(config: { url: string }) {\n this.redis = new Redis(config.url);\n }\n\n async get(key: string, callback?: (...args: any[]) => void): Promise<any | null> {\n if (callback) {\n return this.redis.get(key, callback);\n }\n const data = await this.redis.get(key);\n return data;\n }\n\n async set(key: string, value: string, options?: { ex?: number }): Promise<string> {\n if (options?.ex) {\n return await this.redis.set(key, value, 'EX', options?.ex);\n } else {\n return await this.redis.set(key, value);\n }\n }\n\n async delMulti(keys: string[]): Promise<any> {\n return await this.redis.del(keys);\n }\n\n async del(key: string): Promise<number> {\n return await this.redis.del(key);\n }\n\n on(event: string, cb: (...args: any[]) => void) {\n return this.redis.on(event, cb);\n }\n\n once(event: string, cb: (...args: any[]) => void) {\n return this.redis.once(event, cb);\n }\n}\n"],"names":[],"mappings":"iCAGa,aAAa,CAAA;AACd,IAAA,KAAK,CAAQ;AAErB,IAAA,WAAA,CAAY,MAAuB,EAAA;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACtC;AAED,IAAA,MAAM,GAAG,CAAC,GAAW,EAAE,QAAmC,EAAA;QACtD,IAAI,QAAQ,EAAE;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;SACxC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACvC,QAAA,OAAO,IAAI,CAAC;KACf;AAED,IAAA,MAAM,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,OAAyB,EAAA;AAC3D,QAAA,IAAI,OAAO,EAAE,EAAE,EAAE;AACb,YAAA,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;SAC9D;aAAM;YACH,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SAC3C;KACJ;IAED,MAAM,QAAQ,CAAC,IAAc,EAAA;QACzB,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KACrC;IAED,MAAM,GAAG,CAAC,GAAW,EAAA;QACjB,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACpC;IAED,EAAE,CAAC,KAAa,EAAE,EAA4B,EAAA;QAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KACnC;IAED,IAAI,CAAC,KAAa,EAAE,EAA4B,EAAA;QAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KACrC;AACJ"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { IRedisClient } from 'common/server';
|
|
1
|
+
import type { IRedisClient } from 'common/server';
|
|
2
2
|
export declare class UpstashRedisClient implements IRedisClient {
|
|
3
3
|
private redis;
|
|
4
4
|
constructor(config: {
|
|
5
5
|
url: string;
|
|
6
6
|
token?: string;
|
|
7
7
|
});
|
|
8
|
-
get(key: string): Promise<any | null>;
|
|
8
|
+
get(key: string, callback?: (...args: any[]) => void): Promise<any | null>;
|
|
9
9
|
set(key: string, value: string, options?: {
|
|
10
10
|
ex?: number;
|
|
11
11
|
}): Promise<string>;
|
|
12
12
|
delMulti(keys: string[]): Promise<any>;
|
|
13
13
|
del(key: string): Promise<number>;
|
|
14
|
+
on(event: string, cb: (...args: any[]) => void): this;
|
|
15
|
+
once(event: string, cb: (...args: any[]) => void): this;
|
|
14
16
|
}
|
|
@@ -3,7 +3,13 @@ import {Redis}from'@upstash/redis/cloudflare';class UpstashRedisClient {
|
|
|
3
3
|
constructor(config) {
|
|
4
4
|
this.redis = new Redis({ url: config.url, token: config.token });
|
|
5
5
|
}
|
|
6
|
-
async get(key) {
|
|
6
|
+
async get(key, callback) {
|
|
7
|
+
if (callback) {
|
|
8
|
+
// Upstash doesn't support callbacks, emulate by calling callback with result
|
|
9
|
+
const result = await this.redis.get(key);
|
|
10
|
+
callback(null, result);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
7
13
|
return await this.redis.get(key);
|
|
8
14
|
}
|
|
9
15
|
async set(key, value, options) {
|
|
@@ -20,4 +26,16 @@ import {Redis}from'@upstash/redis/cloudflare';class UpstashRedisClient {
|
|
|
20
26
|
async del(key) {
|
|
21
27
|
return await this.redis.del(key);
|
|
22
28
|
}
|
|
29
|
+
on(event, cb) {
|
|
30
|
+
// Upstash Redis doesn't support event listeners like ioredis
|
|
31
|
+
// This is a no-op implementation for interface compatibility
|
|
32
|
+
console.warn('Upstash Redis does not support event listeners');
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
once(event, cb) {
|
|
36
|
+
// Upstash Redis doesn't support event listeners like ioredis
|
|
37
|
+
// This is a no-op implementation for interface compatibility
|
|
38
|
+
console.warn('Upstash Redis does not support event listeners');
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
23
41
|
}export{UpstashRedisClient};//# sourceMappingURL=upstash-redis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upstash-redis.js","sources":["../../src/core/upstash-redis.ts"],"sourcesContent":["import { Redis } from '@upstash/redis/cloudflare';\nimport { IRedisClient } from 'common/server';\n\nexport class UpstashRedisClient implements IRedisClient {\n private redis: Redis;\n\n constructor(config: { url: string; token?: string }) {\n this.redis = new Redis({ url: config.url, token: config.token });\n }\n\n async get(key: string): Promise<any | null> {\n return await this.redis.get(key);\n }\n\n async set(key: string, value: string, options?: { ex?: number }): Promise<string> {\n if (options?.ex) {\n return await this.redis.set(key, value, { ex: options?.ex });\n } else {\n return await this.redis.set(key, value);\n }\n }\n\n async delMulti(keys: string[]): Promise<any> {\n return await Promise.all(keys.map((key) => this.redis.del(key)));\n }\n\n async del(key: string): Promise<number> {\n return await this.redis.del(key);\n }\n}\n"],"names":[],"mappings":"oDAGa,kBAAkB,CAAA;AACnB,IAAA,KAAK,CAAQ;AAErB,IAAA,WAAA,CAAY,MAAuC,EAAA;QAC/C,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;KACpE;
|
|
1
|
+
{"version":3,"file":"upstash-redis.js","sources":["../../src/core/upstash-redis.ts"],"sourcesContent":["import { Redis } from '@upstash/redis/cloudflare';\nimport type { IRedisClient } from 'common/server';\n\nexport class UpstashRedisClient implements IRedisClient {\n private redis: Redis;\n\n constructor(config: { url: string; token?: string }) {\n this.redis = new Redis({ url: config.url, token: config.token });\n }\n\n async get(key: string, callback?: (...args: any[]) => void): Promise<any | null> {\n if (callback) {\n // Upstash doesn't support callbacks, emulate by calling callback with result\n const result = await this.redis.get(key);\n callback(null, result);\n return result;\n }\n return await this.redis.get(key);\n }\n\n async set(key: string, value: string, options?: { ex?: number }): Promise<string> {\n if (options?.ex) {\n return await this.redis.set(key, value, { ex: options?.ex });\n } else {\n return await this.redis.set(key, value);\n }\n }\n\n async delMulti(keys: string[]): Promise<any> {\n return await Promise.all(keys.map((key) => this.redis.del(key)));\n }\n\n async del(key: string): Promise<number> {\n return await this.redis.del(key);\n }\n\n on(event: string, cb: (...args: any[]) => void) {\n // Upstash Redis doesn't support event listeners like ioredis\n // This is a no-op implementation for interface compatibility\n console.warn('Upstash Redis does not support event listeners');\n return this;\n }\n\n once(event: string, cb: (...args: any[]) => void) {\n // Upstash Redis doesn't support event listeners like ioredis\n // This is a no-op implementation for interface compatibility\n console.warn('Upstash Redis does not support event listeners');\n return this;\n }\n}\n"],"names":[],"mappings":"oDAGa,kBAAkB,CAAA;AACnB,IAAA,KAAK,CAAQ;AAErB,IAA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AAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;AAC/D,QAAA,OAAO,IAAI,CAAC;KACf;IAED,IAAI,CAAC,KAAa,EAAE,EAA4B,EAAA;;;AAG5C,QAAA,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;AAC/D,QAAA,OAAO,IAAI,CAAC;KACf;AACJ"}
|
package/lib/index.d.ts
CHANGED
package/lib/module.d.ts
CHANGED
package/lib/module.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {Feature}from'@common-stack/server-core';import {infraContainer}from'./containers/container.js';
|
|
1
|
+
import {Feature}from'@common-stack/server-core';import {SERVER_TYPES}from'common/server';import {infraContainer}from'./containers/container.js';const redisServiceGen = (container) => ({
|
|
2
|
+
redisCacheManager: container.get(SERVER_TYPES.RedisCacheManager),
|
|
3
|
+
});
|
|
4
|
+
var module = new Feature({
|
|
2
5
|
createContainerFunc: [infraContainer],
|
|
6
|
+
createServiceFunc: [redisServiceGen],
|
|
3
7
|
createMicroServiceContainerFunc: [infraContainer],
|
|
4
|
-
});export{module as default};//# sourceMappingURL=module.js.map
|
|
8
|
+
});export{module as default,redisServiceGen};//# sourceMappingURL=module.js.map
|
package/lib/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sources":["../src/module.ts"],"sourcesContent":["import { Feature } from '@common-stack/server-core';\nimport { infraContainer } from './containers';\n\nexport default new Feature({\n createContainerFunc: [infraContainer],\n createMicroServiceContainerFunc: [infraContainer],\n});\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../src/module.ts"],"sourcesContent":["import { Feature } from '@common-stack/server-core';\nimport type { interfaces } from 'inversify';\nimport { type IRedisCacheManager, SERVER_TYPES } from 'common/server';\nimport { infraContainer } from './containers';\n\nexport const redisServiceGen = (container: interfaces.Container) => ({\n redisCacheManager: container.get<IRedisCacheManager>(SERVER_TYPES.RedisCacheManager),\n});\n\nexport default new Feature({\n createContainerFunc: [infraContainer],\n createServiceFunc: [redisServiceGen],\n createMicroServiceContainerFunc: [infraContainer],\n});\n"],"names":[],"mappings":"sJAKa,eAAe,GAAG,CAAC,SAA+B,MAAM;IACjE,iBAAiB,EAAE,SAAS,CAAC,GAAG,CAAqB,YAAY,CAAC,iBAAiB,CAAC;AACvF,CAAA,EAAE;AAEH,aAAe,IAAI,OAAO,CAAC;IACvB,mBAAmB,EAAE,CAAC,cAAc,CAAC;IACrC,iBAAiB,EAAE,CAAC,eAAe,CAAC;IACpC,+BAA+B,EAAE,CAAC,cAAc,CAAC;AACpD,CAAA,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export interface IRedisClient {
|
|
2
2
|
get?(key: string): Promise<string | null>;
|
|
3
3
|
get?(key: string, callback?: (...args: any[]) => void): any;
|
|
4
|
-
set(key: string, value: string, options?: {
|
|
5
|
-
ex?: number;
|
|
6
|
-
}): Promise<string>;
|
|
4
|
+
set(key: string, value: string, options?: { ex?: number }): Promise<string>;
|
|
7
5
|
del(key: string): Promise<number>;
|
|
8
6
|
delMulti(keys: string[]): Promise<any>;
|
|
9
7
|
on?(event: string | symbol, callback: (...args: any[]) => void): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/store-redis",
|
|
3
|
-
"version": "8.3.1-alpha.
|
|
3
|
+
"version": "8.3.1-alpha.1",
|
|
4
4
|
"description": "Redis store utilities and services for common-stack",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"watch": "npm run build:lib:watch"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@common-stack/core": "8.3.1-alpha.
|
|
27
|
+
"@common-stack/core": "8.3.1-alpha.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"common": "8.
|
|
30
|
+
"common": "8.3.1-alpha.1",
|
|
31
31
|
"ioredis": "^5.3.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"./${libDir}/templates/constants/SERVER_TYPES.ts.template"
|
|
45
45
|
],
|
|
46
46
|
"repositories": [
|
|
47
|
-
"./${libDir}/templates/repositories/
|
|
47
|
+
"./${libDir}/templates/repositories/RedisKeyBuilder.ts.template",
|
|
48
|
+
"./${libDir}/templates/repositories/RedisClient.ts.template",
|
|
48
49
|
"./${libDir}/templates/repositories/redisCommonTypes.ts.template"
|
|
49
50
|
],
|
|
50
51
|
"services": [
|
|
@@ -55,5 +56,5 @@
|
|
|
55
56
|
"typescript": {
|
|
56
57
|
"definition": "lib/index.d.ts"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "2c4079698de454299caed4ecd2315ef29cbff740"
|
|
59
60
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './redis';
|
/package/lib/templates/repositories/{IRedisKeyBuilder.ts.template → RedisKeyBuilder.ts.template}
RENAMED
|
File without changes
|