@acmekit/cache-redis 2.13.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/README.md +27 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/initialize/index.d.ts +4 -0
- package/dist/initialize/index.d.ts.map +1 -0
- package/dist/initialize/index.js +16 -0
- package/dist/initialize/index.js.map +1 -0
- package/dist/loaders/index.d.ts +4 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/index.js +29 -0
- package/dist/loaders/index.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +9 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/redis-cache.d.ts +40 -0
- package/dist/services/redis-cache.d.ts.map +1 -0
- package/dist/services/redis-cache.js +76 -0
- package/dist/services/redis-cache.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +30 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# AcmeKit Cache Redis
|
|
2
|
+
|
|
3
|
+
Use Redis as a AcmeKit cache store.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn add @acmekit/cache-redis
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
{
|
|
15
|
+
ttl?: number // Time to keep data in cache (in seconds)
|
|
16
|
+
|
|
17
|
+
redisUrl?: string // Redis instance connection string
|
|
18
|
+
|
|
19
|
+
redisOptions?: RedisOptions // Redis client options
|
|
20
|
+
|
|
21
|
+
namespace?: string // Prefix for event keys (the default is `acmekit:`)
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Other caching modules
|
|
26
|
+
|
|
27
|
+
- [AcmeKit Cache In-Memory](../cache-inmemory/README.md)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAOxD,QAAA,MAAM,gBAAgB,EAAE,aAGvB,CAAA;AAED,eAAe,gBAAgB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const loaders_1 = __importDefault(require("./loaders"));
|
|
21
|
+
const services_1 = require("./services");
|
|
22
|
+
const service = services_1.RedisCacheService;
|
|
23
|
+
const loaders = [loaders_1.default];
|
|
24
|
+
const moduleDefinition = {
|
|
25
|
+
service,
|
|
26
|
+
loaders,
|
|
27
|
+
};
|
|
28
|
+
exports.default = moduleDefinition;
|
|
29
|
+
__exportStar(require("./initialize"), exports);
|
|
30
|
+
__exportStar(require("./types"), exports);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AACA,wDAA8B;AAC9B,yCAA8C;AAE9C,MAAM,OAAO,GAAG,4BAAiB,CAAA;AACjC,MAAM,OAAO,GAAG,CAAC,iBAAM,CAAC,CAAA;AAExB,MAAM,gBAAgB,GAAkB;IACtC,OAAO;IACP,OAAO;CACR,CAAA;AAED,kBAAe,gBAAgB,CAAA;AAC/B,+CAA4B;AAC5B,0CAAuB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExternalModuleDeclaration, ICacheService } from "@acmekit/framework/types";
|
|
2
|
+
import { RedisCacheModuleOptions } from "../types";
|
|
3
|
+
export declare const initialize: (options?: RedisCacheModuleOptions | ExternalModuleDeclaration) => Promise<ICacheService>;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,aAAa,EAEd,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAElD,eAAO,MAAM,UAAU,GACrB,UAAU,uBAAuB,GAAG,yBAAyB,KAC5D,OAAO,CAAC,aAAa,CAWvB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initialize = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@acmekit/framework/modules-sdk");
|
|
5
|
+
const utils_1 = require("@acmekit/framework/utils");
|
|
6
|
+
const initialize = async (options) => {
|
|
7
|
+
const serviceKey = utils_1.Modules.CACHE;
|
|
8
|
+
const loaded = await modules_sdk_1.AcmeKitModule.bootstrap({
|
|
9
|
+
moduleKey: serviceKey,
|
|
10
|
+
defaultPath: "@acmekit/cache-redis",
|
|
11
|
+
declaration: options,
|
|
12
|
+
});
|
|
13
|
+
return loaded[serviceKey];
|
|
14
|
+
};
|
|
15
|
+
exports.initialize = initialize;
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":";;;AAAA,gEAA8D;AAM9D,oDAAkD;AAG3C,MAAM,UAAU,GAAG,KAAK,EAC7B,OAA6D,EACrC,EAAE;IAC1B,MAAM,UAAU,GAAG,eAAO,CAAC,KAAK,CAAA;IAChC,MAAM,MAAM,GAAG,MAAM,2BAAa,CAAC,SAAS,CAAgB;QAC1D,SAAS,EAAE,UAAU;QACrB,WAAW,EAAE,sBAAsB;QACnC,WAAW,EAAE,OAEgB;KAC9B,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,UAAU,CAAC,CAAA;AAC3B,CAAC,CAAA;AAbY,QAAA,UAAU,cAatB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;yBAKlC,iCAInB,aAAa,KAAG,OAAO,CAAC,IAAI,CAAC;AAJhC,wBA+BC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const awilix_1 = require("@acmekit/framework/awilix");
|
|
7
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
8
|
+
exports.default = async ({ container, logger, options, }) => {
|
|
9
|
+
const { redisUrl, redisOptions } = options;
|
|
10
|
+
if (!redisUrl) {
|
|
11
|
+
throw Error("No `redisUrl` provided in `cacheService` module options. It is required for the Redis Cache Module.");
|
|
12
|
+
}
|
|
13
|
+
const connection = new ioredis_1.default(redisUrl, {
|
|
14
|
+
// Lazy connect to properly handle connection errors
|
|
15
|
+
lazyConnect: true,
|
|
16
|
+
...(redisOptions ?? {}),
|
|
17
|
+
});
|
|
18
|
+
try {
|
|
19
|
+
await connection.connect();
|
|
20
|
+
logger?.info(`Connection to Redis in module 'cache-redis' established`);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
logger?.error(`An error occurred while connecting to Redis in module 'cache-redis': ${err}`);
|
|
24
|
+
}
|
|
25
|
+
container.register({
|
|
26
|
+
cacheRedisConnection: (0, awilix_1.asValue)(connection),
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":";;;;;AACA,sDAAmD;AACnD,sDAA2B;AAG3B,kBAAe,KAAK,EAAE,EACpB,SAAS,EACT,MAAM,EACN,OAAO,GACO,EAAiB,EAAE;IACjC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,OAAkC,CAAA;IAErE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CACT,qGAAqG,CACtG,CAAA;IACH,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,iBAAK,CAAC,QAAQ,EAAE;QACrC,oDAAoD;QACpD,WAAW,EAAE,IAAI;QACjB,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;KACxB,CAAC,CAAA;IAEF,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;QAC1B,MAAM,EAAE,IAAI,CAAC,yDAAyD,CAAC,CAAA;IACzE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,EAAE,KAAK,CACX,wEAAwE,GAAG,EAAE,CAC9E,CAAA;IACH,CAAC;IAED,SAAS,CAAC,QAAQ,CAAC;QACjB,oBAAoB,EAAE,IAAA,gBAAO,EAAC,UAAU,CAAC;KAC1C,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RedisCacheService = void 0;
|
|
7
|
+
var redis_cache_1 = require("./redis-cache");
|
|
8
|
+
Object.defineProperty(exports, "RedisCacheService", { enumerable: true, get: function () { return __importDefault(redis_cache_1).default; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4D;AAAnD,iIAAA,OAAO,OAAqB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ICacheService } from "@acmekit/framework/types";
|
|
2
|
+
import { Redis } from "ioredis";
|
|
3
|
+
import { RedisCacheModuleOptions } from "../types";
|
|
4
|
+
type InjectedDependencies = {
|
|
5
|
+
cacheRedisConnection: Redis;
|
|
6
|
+
};
|
|
7
|
+
declare class RedisCacheService implements ICacheService {
|
|
8
|
+
protected readonly TTL: number;
|
|
9
|
+
protected readonly redis: Redis;
|
|
10
|
+
private readonly namespace;
|
|
11
|
+
constructor({ cacheRedisConnection }: InjectedDependencies, options?: RedisCacheModuleOptions);
|
|
12
|
+
__hooks: {
|
|
13
|
+
onApplicationShutdown: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Set a key/value pair to the cache.
|
|
17
|
+
* If the ttl is 0 it will act like the value should not be cached at all.
|
|
18
|
+
* @param key
|
|
19
|
+
* @param data
|
|
20
|
+
* @param ttl
|
|
21
|
+
*/
|
|
22
|
+
set(key: string, data: Record<string, unknown>, ttl?: number): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieve a cached value belonging to the given key.
|
|
25
|
+
* @param cacheKey
|
|
26
|
+
*/
|
|
27
|
+
get<T>(cacheKey: string): Promise<T | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Invalidate cache for a specific key. a key can be either a specific key or more global such as "ps:*".
|
|
30
|
+
* @param key
|
|
31
|
+
*/
|
|
32
|
+
invalidate(key: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns namespaced cache key
|
|
35
|
+
* @param key
|
|
36
|
+
*/
|
|
37
|
+
private getCacheKey;
|
|
38
|
+
}
|
|
39
|
+
export default RedisCacheService;
|
|
40
|
+
//# sourceMappingURL=redis-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-cache.d.ts","sourceRoot":"","sources":["../../src/services/redis-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAMlD,KAAK,oBAAoB,GAAG;IAC1B,oBAAoB,EAAE,KAAK,CAAA;CAC5B,CAAA;AAED,cAAM,iBAAkB,YAAW,aAAa;IAC9C,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAC9B,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;gBAGhC,EAAE,oBAAoB,EAAE,EAAE,oBAAoB,EAC9C,OAAO,GAAE,uBAA4B;IAOvC,OAAO;;MAIN;IAED;;;;;;OAMG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,GAAE,MAAiB,GACrB,OAAO,CAAC,IAAI,CAAC;IAahB;;;OAGG;IACG,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAajD;;;OAGG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB5C;;;OAGG;IACH,OAAO,CAAC,WAAW;CAGpB;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const DEFAULT_NAMESPACE = "acmekit";
|
|
4
|
+
const DEFAULT_CACHE_TIME = 30; // 30 seconds
|
|
5
|
+
const EXPIRY_MODE = "EX"; // "EX" stands for an expiry time in second
|
|
6
|
+
class RedisCacheService {
|
|
7
|
+
constructor({ cacheRedisConnection }, options = {}) {
|
|
8
|
+
this.__hooks = {
|
|
9
|
+
onApplicationShutdown: async () => {
|
|
10
|
+
this.redis.disconnect();
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
this.redis = cacheRedisConnection;
|
|
14
|
+
this.TTL = options.ttl ?? DEFAULT_CACHE_TIME;
|
|
15
|
+
this.namespace = options.namespace || DEFAULT_NAMESPACE;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Set a key/value pair to the cache.
|
|
19
|
+
* If the ttl is 0 it will act like the value should not be cached at all.
|
|
20
|
+
* @param key
|
|
21
|
+
* @param data
|
|
22
|
+
* @param ttl
|
|
23
|
+
*/
|
|
24
|
+
async set(key, data, ttl = this.TTL) {
|
|
25
|
+
if (ttl === 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
await this.redis.set(this.getCacheKey(key), JSON.stringify(data), EXPIRY_MODE, ttl);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve a cached value belonging to the given key.
|
|
32
|
+
* @param cacheKey
|
|
33
|
+
*/
|
|
34
|
+
async get(cacheKey) {
|
|
35
|
+
cacheKey = this.getCacheKey(cacheKey);
|
|
36
|
+
try {
|
|
37
|
+
const cached = await this.redis.get(cacheKey);
|
|
38
|
+
if (cached) {
|
|
39
|
+
return JSON.parse(cached);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
await this.redis.unlink(cacheKey);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Invalidate cache for a specific key. a key can be either a specific key or more global such as "ps:*".
|
|
49
|
+
* @param key
|
|
50
|
+
*/
|
|
51
|
+
async invalidate(key) {
|
|
52
|
+
const pattern = this.getCacheKey(key);
|
|
53
|
+
let cursor = "0";
|
|
54
|
+
do {
|
|
55
|
+
const result = await this.redis.scan(cursor, "MATCH", pattern, "COUNT", 100);
|
|
56
|
+
cursor = result[0];
|
|
57
|
+
const keys = result[1];
|
|
58
|
+
if (keys.length > 0) {
|
|
59
|
+
const deletePipeline = this.redis.pipeline();
|
|
60
|
+
for (const key of keys) {
|
|
61
|
+
deletePipeline.unlink(key);
|
|
62
|
+
}
|
|
63
|
+
await deletePipeline.exec();
|
|
64
|
+
}
|
|
65
|
+
} while (cursor !== "0");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns namespaced cache key
|
|
69
|
+
* @param key
|
|
70
|
+
*/
|
|
71
|
+
getCacheKey(key) {
|
|
72
|
+
return this.namespace ? `${this.namespace}:${key}` : key;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.default = RedisCacheService;
|
|
76
|
+
//# sourceMappingURL=redis-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-cache.js","sourceRoot":"","sources":["../../src/services/redis-cache.ts"],"names":[],"mappings":";;AAIA,MAAM,iBAAiB,GAAG,SAAS,CAAA;AACnC,MAAM,kBAAkB,GAAG,EAAE,CAAA,CAAC,aAAa;AAC3C,MAAM,WAAW,GAAG,IAAI,CAAA,CAAC,2CAA2C;AAMpE,MAAM,iBAAiB;IAKrB,YACE,EAAE,oBAAoB,EAAwB,EAC9C,UAAmC,EAAE;QAOvC,YAAO,GAAG;YACR,qBAAqB,EAAE,KAAK,IAAI,EAAE;gBAChC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;YACzB,CAAC;SACF,CAAA;QATC,IAAI,CAAC,KAAK,GAAG,oBAAoB,CAAA;QACjC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,kBAAkB,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAA;IACzD,CAAC;IAQD;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CACP,GAAW,EACX,IAA6B,EAC7B,MAAc,IAAI,CAAC,GAAG;QAEtB,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;YACd,OAAM;QACR,CAAC;QAED,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAClB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EACrB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EACpB,WAAW,EACX,GAAG,CACJ,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAI,QAAgB;QAC3B,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC7C,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QACnC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,GAAW;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QACrC,IAAI,MAAM,GAAG,GAAG,CAAA;QAChB,GAAG,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAClC,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,GAAG,CACJ,CAAA;YACD,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YAClB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YAEtB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpB,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;gBAC5C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;oBACvB,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAC5B,CAAC;gBAED,MAAM,cAAc,CAAC,IAAI,EAAE,CAAA;YAC7B,CAAC;QACH,CAAC,QAAQ,MAAM,KAAK,GAAG,EAAC;IAC1B,CAAC;IAED;;;OAGG;IACK,WAAW,CAAC,GAAW;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;IAC1D,CAAC;CACF;AAED,kBAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/index.ts","../src/initialize/index.ts","../src/loaders/index.ts","../src/services/index.ts","../src/services/redis-cache.ts","../src/services/__tests__/redis-cache.js","../src/types/index.ts"],"version":"5.9.3"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RedisOptions } from "ioredis";
|
|
2
|
+
/**
|
|
3
|
+
* Module config type
|
|
4
|
+
*/
|
|
5
|
+
export type RedisCacheModuleOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Time to keep data in cache (in seconds)
|
|
8
|
+
*/
|
|
9
|
+
ttl?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Redis connection string
|
|
12
|
+
*/
|
|
13
|
+
redisUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Redis client options
|
|
16
|
+
*/
|
|
17
|
+
redisOptions?: RedisOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Prefix for event keys
|
|
20
|
+
* @default `acmekit:`
|
|
21
|
+
*/
|
|
22
|
+
namespace?: string;
|
|
23
|
+
};
|
|
24
|
+
declare module "@acmekit/types" {
|
|
25
|
+
interface ModuleOptions {
|
|
26
|
+
"@acmekit/cache-redis": RedisCacheModuleOptions;
|
|
27
|
+
"@acmekit/acmekit/cache-redis": RedisCacheModuleOptions;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAA;IAE3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,aAAa;QACrB,sBAAsB,EAAE,uBAAuB,CAAA;QAC/C,8BAA8B,EAAE,uBAAuB,CAAA;KACxD;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@acmekit/cache-redis",
|
|
3
|
+
"version": "2.13.1",
|
|
4
|
+
"description": "Redis Cache Module for AcmeKit",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/acmekit/acmekit",
|
|
9
|
+
"directory": "packages/modules/cache-redis"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"!dist/**/__tests__",
|
|
20
|
+
"!dist/**/__mocks__",
|
|
21
|
+
"!dist/**/__fixtures__"
|
|
22
|
+
],
|
|
23
|
+
"author": "AcmeKit",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@acmekit/framework": "2.13.1"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"watch": "yarn run -T tsc --build --watch",
|
|
30
|
+
"build": "yarn run -T rimraf dist && yarn run -T tsc --build",
|
|
31
|
+
"test": "../../../node_modules/.bin/jest --passWithNoTests"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"ioredis": "^5.4.1"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@acmekit/framework": "2.13.1"
|
|
38
|
+
}
|
|
39
|
+
}
|