@chat-adapter/state-redis 4.0.0 → 4.0.2
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/LICENSE +9 -0
- package/README.md +78 -0
- package/package.json +11 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vercel, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @chat-adapter/state-redis
|
|
2
|
+
|
|
3
|
+
Redis state adapter for the [chat](https://github.com/vercel-labs/chat) SDK using the official [redis](https://www.npmjs.com/package/redis) package.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install chat @chat-adapter/state-redis redis
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Chat } from "chat";
|
|
15
|
+
import { createRedisState } from "@chat-adapter/state-redis";
|
|
16
|
+
|
|
17
|
+
const chat = new Chat({
|
|
18
|
+
userName: "mybot",
|
|
19
|
+
adapters: { /* ... */ },
|
|
20
|
+
state: createRedisState({
|
|
21
|
+
url: process.env.REDIS_URL!,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
| Option | Required | Description |
|
|
29
|
+
|--------|----------|-------------|
|
|
30
|
+
| `url` | Yes* | Redis connection URL |
|
|
31
|
+
| `client` | No | Existing redis client instance |
|
|
32
|
+
| `keyPrefix` | No | Prefix for all keys (default: `"chat-sdk"`) |
|
|
33
|
+
|
|
34
|
+
*Either `url` or `client` is required.
|
|
35
|
+
|
|
36
|
+
### Using Connection URL
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const state = createRedisState({
|
|
40
|
+
url: "redis://localhost:6379",
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Using Existing Client
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { createClient } from "redis";
|
|
48
|
+
|
|
49
|
+
const client = createClient({ url: "redis://localhost:6379" });
|
|
50
|
+
await client.connect();
|
|
51
|
+
|
|
52
|
+
const state = createRedisState({ client });
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
- Thread subscriptions (persistent)
|
|
58
|
+
- Distributed locking (works across instances)
|
|
59
|
+
- Automatic reconnection
|
|
60
|
+
- Key prefix namespacing
|
|
61
|
+
|
|
62
|
+
## Key Structure
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
{keyPrefix}:subscriptions - SET of subscribed thread IDs
|
|
66
|
+
{keyPrefix}:lock:{threadId} - Lock key with TTL
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Production Recommendations
|
|
70
|
+
|
|
71
|
+
- Use Redis 6.0+ for best performance
|
|
72
|
+
- Enable Redis persistence (RDB or AOF)
|
|
73
|
+
- Use Redis Cluster for high availability
|
|
74
|
+
- Set appropriate memory limits
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chat-adapter/state-redis",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Redis state adapter for chat (production)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,16 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"redis": "^4.7.0",
|
|
20
|
-
"chat": "4.0.
|
|
20
|
+
"chat": "4.0.2"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/vercel-labs/chat.git",
|
|
25
|
+
"directory": "packages/state-redis"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/vercel-labs/chat#readme",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/vercel-labs/chat/issues"
|
|
21
30
|
},
|
|
22
31
|
"publishConfig": {
|
|
23
32
|
"access": "public"
|