@antelopejs/redis 1.0.3 → 1.0.4
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 +80 -42
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +40 -27
package/README.md
CHANGED
|
@@ -1,75 +1,113 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
1
|
# @antelopejs/redis
|
|
4
2
|
|
|
5
3
|
<div align="center">
|
|
6
|
-
<a href="https://www.npmjs.com/package/@antelopejs/redis"><img alt="
|
|
7
|
-
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/redis
|
|
4
|
+
<a href="https://www.npmjs.com/package/@antelopejs/redis"><img alt="npm" src="https://img.shields.io/npm/v/@antelopejs/redis?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
5
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/redis?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
8
6
|
<a href="https://discord.gg/sjK28QHrA7"><img src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000" alt="Discord"></a>
|
|
9
|
-
<a href="https://antelopejs.com/
|
|
7
|
+
<a href="https://interfaces.antelopejs.com/docs/redis/introduction"><img src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000" alt="Documentation"></a>
|
|
10
8
|
</div>
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
The Redis module of AntelopeJS: it connects one shared [`ioredis`](https://github.com/redis/ioredis) client and serves it to the Redis and Redis Scheduler interfaces.
|
|
11
|
+
|
|
12
|
+
## Interfaces
|
|
13
|
+
|
|
14
|
+
| Interface | Documentation |
|
|
15
|
+
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
16
|
+
| [`@antelopejs/interface-redis`](https://github.com/AntelopeJS/interface-redis) | [Redis](https://interfaces.antelopejs.com/docs/redis/introduction) |
|
|
17
|
+
| [`@antelopejs/interface-redis-scheduler`](https://github.com/AntelopeJS/interface-redis-scheduler) | [Redis Scheduler](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction) |
|
|
18
|
+
|
|
19
|
+
The scheduler runs inside the interface package on top of the Redis client, so this module is all it needs.
|
|
13
20
|
|
|
14
|
-
##
|
|
21
|
+
## Install
|
|
15
22
|
|
|
16
23
|
```bash
|
|
17
24
|
ajs project modules add @antelopejs/redis
|
|
18
25
|
```
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
This module implements two key interfaces:
|
|
27
|
+
The command writes the module's default configuration: `redis://localhost:6379`.
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
- **Redis Scheduler Interface**: Redis-based distributed task scheduler with job queuing and automatic retries.
|
|
29
|
+
## Configuration
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
```typescript [antelope.config.ts]
|
|
32
|
+
import { defineConfig } from "@antelopejs/interface-core/config";
|
|
33
|
+
|
|
34
|
+
export default defineConfig({
|
|
35
|
+
name: "my-project",
|
|
36
|
+
modules: {
|
|
37
|
+
redis: {
|
|
38
|
+
source: {
|
|
39
|
+
type: "package",
|
|
40
|
+
package: "@antelopejs/redis",
|
|
41
|
+
version: "^1.0.3",
|
|
42
|
+
},
|
|
43
|
+
config: {
|
|
44
|
+
url: "redis://localhost:6379",
|
|
45
|
+
useMock: false,
|
|
46
|
+
lazyConnect: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
envOverrides: {
|
|
51
|
+
REDIS_URL: "modules.redis.config.url",
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
```
|
|
28
55
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
56
|
+
| Key | Description |
|
|
57
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| `url` | Redis connection URL. Optional: without it, the client uses the options below, or `localhost:6379`. |
|
|
59
|
+
| `useMock` | Serve an in-memory [`ioredis-mock`](https://github.com/stipsan/ioredis-mock) client instead of connecting. For tests only. |
|
|
60
|
+
| any other key | Passed to the client as [`ioredis` options](https://github.com/redis/ioredis#connect-to-redis) (`host`, `port`, `password`, `db`, `tls`, `lazyConnect`…). |
|
|
33
61
|
|
|
34
|
-
|
|
62
|
+
The client connects when the module starts, and quits when it stops.
|
|
35
63
|
|
|
36
|
-
|
|
64
|
+
## Quick start
|
|
37
65
|
|
|
38
|
-
|
|
39
|
-
- Task scheduling with retry capabilities
|
|
66
|
+
In the module that uses Redis, add the interface:
|
|
40
67
|
|
|
41
|
-
|
|
68
|
+
```bash
|
|
69
|
+
pnpm add @antelopejs/interface-redis
|
|
70
|
+
```
|
|
42
71
|
|
|
43
|
-
|
|
72
|
+
```typescript
|
|
73
|
+
import { GetClient } from "@antelopejs/interface-redis";
|
|
44
74
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"lazyConnect": true
|
|
49
|
-
}
|
|
75
|
+
const client = await GetClient();
|
|
76
|
+
await client.set("greeting", "hello", "EX", 60);
|
|
77
|
+
const greeting = await client.get("greeting");
|
|
50
78
|
```
|
|
51
79
|
|
|
52
|
-
|
|
80
|
+
`GetClient()` waits until the module has connected. For distributed jobs, add `@antelopejs/interface-redis-scheduler` and read its [documentation](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction).
|
|
53
81
|
|
|
54
|
-
|
|
82
|
+
## Documentation
|
|
55
83
|
|
|
56
|
-
-
|
|
57
|
-
-
|
|
84
|
+
- [Redis](https://interfaces.antelopejs.com/docs/redis/introduction): the `@antelopejs/interface-redis` contract this module implements
|
|
85
|
+
- [Redis Scheduler](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction): the `@antelopejs/interface-redis-scheduler` contract this module implements
|
|
86
|
+
- [Configuration](https://framework.antelopejs.com/docs/concepts/configuration): module sources, `config` blocks and config variables in `antelope.config.ts`
|
|
58
87
|
|
|
59
|
-
##
|
|
88
|
+
## Compatibility
|
|
60
89
|
|
|
61
|
-
|
|
90
|
+
| Package | Supported range |
|
|
91
|
+
| --------------------------------------- | ---------------- |
|
|
92
|
+
| `@antelopejs/interface-redis` | `>=0.0.9 <1.0.0` |
|
|
93
|
+
| `@antelopejs/interface-redis-scheduler` | `>=0.0.8 <1.0.0` |
|
|
94
|
+
| `@antelopejs/interface-core` | `>=0.2.4 <1.0.0` |
|
|
62
95
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
96
|
+
The module is developed and tested against `@antelopejs/core` `^1.16.0` on Node.js 24, with `ioredis` `^5.10.1`.
|
|
97
|
+
|
|
98
|
+
## Contributing
|
|
66
99
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
100
|
+
```bash
|
|
101
|
+
pnpm install
|
|
102
|
+
pnpm dev # run the playground/ project against redis://127.0.0.1:6379
|
|
103
|
+
pnpm lint
|
|
104
|
+
pnpm format:check
|
|
105
|
+
pnpm knip
|
|
106
|
+
pnpm test # build, then ajs module test with ioredis-mock
|
|
71
107
|
```
|
|
72
108
|
|
|
109
|
+
The tests need no Redis server. Read the [contribution guidelines](CONTRIBUTING.md) before opening a pull request.
|
|
110
|
+
|
|
73
111
|
## License
|
|
74
112
|
|
|
75
|
-
|
|
113
|
+
[Apache-2.0](LICENSE)
|
package/dist/index.js
CHANGED
|
@@ -40,8 +40,8 @@ exports.construct = construct;
|
|
|
40
40
|
exports.destroy = destroy;
|
|
41
41
|
exports.start = start;
|
|
42
42
|
exports.stop = stop;
|
|
43
|
-
const interface_redis_1 = require("@antelopejs/interface-redis");
|
|
44
43
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
44
|
+
const interface_redis_1 = require("@antelopejs/interface-redis");
|
|
45
45
|
let redisConfig;
|
|
46
46
|
function construct(config) {
|
|
47
47
|
redisConfig = config;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8BAEC;AAED,0BAAkC;AAElC,sBAMC;AAED,oBAIC;AA3BD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8BAEC;AAED,0BAAkC;AAElC,sBAMC;AAED,oBAIC;AA3BD,sDAAmD;AACnD,iEAAuD;AAOvD,IAAI,WAAwB,CAAC;AAC7B,SAAgB,SAAS,CAAC,MAAmB;IAC3C,WAAW,GAAG,MAAM,CAAC;AACvB,CAAC;AAED,SAAgB,OAAO,KAAU,CAAC;AAE3B,KAAK,UAAU,KAAK;IACzB,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;QACnD,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IACD,0BAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AAEM,KAAK,UAAU,IAAI;IACxB,MAAM,MAAM,GAAG,MAAM,0BAAQ,CAAC,MAAM,CAAC;IACrC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACpB,KAAK,0BAAQ,CAAC,WAAW,EAAE,CAAC;AAC9B,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,MAAmB;IAClD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QAEnB,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,wDAAa,cAAc,GAAC,CAAC;QAC5D,OAAO,IAAI,SAAS,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAqB,CAAC;IAClE,CAAC;IACD,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC;IAC/C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,iBAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,iBAAK,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,iBAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,64 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/redis",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Redis module
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Redis module for AntelopeJS, implementing the Redis and Redis Scheduler interfaces with ioredis",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
7
|
-
"redis",
|
|
8
7
|
"cache",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
8
|
+
"ioredis",
|
|
9
|
+
"redis",
|
|
10
|
+
"scheduler"
|
|
11
11
|
],
|
|
12
|
+
"homepage": "https://interfaces.antelopejs.com/docs/redis/introduction",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/AntelopeJS/redis/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "Apache-2.0",
|
|
12
17
|
"repository": {
|
|
13
18
|
"type": "git",
|
|
14
19
|
"url": "git+https://github.com/AntelopeJS/redis.git"
|
|
15
20
|
},
|
|
16
|
-
"main": "dist/index.js",
|
|
17
21
|
"files": [
|
|
18
22
|
"dist"
|
|
19
23
|
],
|
|
24
|
+
"main": "dist/index.js",
|
|
20
25
|
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
26
|
+
"access": "public",
|
|
27
|
+
"provenance": true
|
|
22
28
|
},
|
|
23
|
-
"license": "Apache-2.0",
|
|
24
|
-
"packageManager": "pnpm@10.6.5",
|
|
25
29
|
"scripts": {
|
|
26
30
|
"build": "rimraf dist && tsc",
|
|
27
31
|
"dev": "ajs project run -w -p playground --inspect",
|
|
28
|
-
"format": "
|
|
29
|
-
"lint:fix": "
|
|
30
|
-
"lint": "
|
|
32
|
+
"format": "oxfmt .",
|
|
33
|
+
"lint:fix": "oxlint --fix",
|
|
34
|
+
"lint": "oxlint",
|
|
31
35
|
"prepack": "pnpm run build",
|
|
32
36
|
"release": "pnpm run lint && pnpm run test && pnpm run prepack && release-it",
|
|
33
|
-
"test": "pnpm run build && ajs module test ."
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"implements": [
|
|
37
|
-
"@antelopejs/interface-redis",
|
|
38
|
-
"@antelopejs/interface-redis-scheduler"
|
|
39
|
-
],
|
|
40
|
-
"defaultConfig": {
|
|
41
|
-
"url": "redis://localhost:6379"
|
|
42
|
-
},
|
|
43
|
-
"test": "src/test/antelope.test.ts"
|
|
37
|
+
"test": "pnpm run build && ajs module test .",
|
|
38
|
+
"format:check": "oxfmt --check .",
|
|
39
|
+
"knip": "knip"
|
|
44
40
|
},
|
|
45
41
|
"dependencies": {
|
|
46
|
-
"@antelopejs/interface-core": ">=0.
|
|
47
|
-
"@antelopejs/interface-redis": ">=0.0.
|
|
48
|
-
"@antelopejs/interface-redis-scheduler": ">=0.0.
|
|
42
|
+
"@antelopejs/interface-core": ">=0.2.4 <1.0.0",
|
|
43
|
+
"@antelopejs/interface-redis": ">=0.0.9 <1.0.0",
|
|
44
|
+
"@antelopejs/interface-redis-scheduler": ">=0.0.8 <1.0.0",
|
|
49
45
|
"ioredis": "^5.10.1",
|
|
50
46
|
"ioredis-mock": "^8.13.1"
|
|
51
47
|
},
|
|
52
48
|
"devDependencies": {
|
|
53
|
-
"@
|
|
49
|
+
"@antelopejs/core": "^1.16.0",
|
|
50
|
+
"@antelopejs/tooling-configs": "^0.0.9",
|
|
54
51
|
"@types/chai": "^4.3.20",
|
|
55
52
|
"@types/ioredis-mock": "^8.2.7",
|
|
56
53
|
"@types/mocha": "^10.0.10",
|
|
57
54
|
"@types/node": "^22.19.15",
|
|
58
55
|
"chai": "^4.5.0",
|
|
56
|
+
"eslint-plugin-perfectionist": "^5.11.0",
|
|
57
|
+
"knip": "^6.34.0",
|
|
58
|
+
"oxfmt": "^0.66.0",
|
|
59
|
+
"oxlint": "1.81.0",
|
|
60
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
59
61
|
"release-it": "^19.2.4",
|
|
60
62
|
"release-it-changelogen": "^0.1.0",
|
|
61
63
|
"rimraf": "^6.1.3",
|
|
62
64
|
"typescript": "^5.9.3"
|
|
65
|
+
},
|
|
66
|
+
"packageManager": "pnpm@10.6.5",
|
|
67
|
+
"antelopeJs": {
|
|
68
|
+
"implements": [
|
|
69
|
+
"@antelopejs/interface-redis",
|
|
70
|
+
"@antelopejs/interface-redis-scheduler"
|
|
71
|
+
],
|
|
72
|
+
"defaultConfig": {
|
|
73
|
+
"url": "redis://localhost:6379"
|
|
74
|
+
},
|
|
75
|
+
"test": "src/test/antelope.test.ts"
|
|
63
76
|
}
|
|
64
77
|
}
|