@mastra/redis 1.4.3-alpha.0 → 1.4.3-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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mastra/redis
2
2
 
3
- Redis storage provider for Mastra that provides storage capabilities for direct Redis connections.
3
+ Store Mastra application data in Redis using connection strings, host settings, or custom clients, including Sentinel and Cluster deployments.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,188 +10,7 @@ npm install @mastra/redis
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Basic Usage
14
-
15
- ```typescript
16
- import { RedisStore } from '@mastra/redis';
17
-
18
- // Using connection string
19
- const storage = new RedisStore({
20
- id: 'my-storage',
21
- connectionString: 'redis://localhost:6379',
22
- });
23
-
24
- // Using host/port config
25
- const storage = new RedisStore({
26
- id: 'my-storage',
27
- host: 'localhost',
28
- port: 6379,
29
- password: 'your-password',
30
- db: 0,
31
- });
32
-
33
- // Initialize (connects to Redis)
34
- await storage.init();
35
- ```
36
-
37
- ### With Pre-configured Client
38
-
39
- ```typescript
40
- import { RedisStore } from '@mastra/redis';
41
- import { createClient } from 'redis';
42
-
43
- // Create a custom redis client with specific settings
44
- const client = createClient({
45
- url: 'redis://localhost:6379',
46
- socket: {
47
- reconnectStrategy: retries => Math.min(retries * 50, 2000),
48
- },
49
- });
50
-
51
- // Connect the client before passing to RedisStore
52
- await client.connect();
53
-
54
- const storage = new RedisStore({
55
- id: 'my-storage',
56
- client,
57
- });
58
- ```
59
-
60
- ## Parameters
61
-
62
- | Parameter | Type | Description |
63
- | ------------------ | ------------- | ------------------------------------------------------ |
64
- | `id` | `string` | Unique identifier for the storage instance |
65
- | `connectionString` | `string` | Redis connection URL (e.g., `redis://localhost:6379`) |
66
- | `host` | `string` | Redis host address |
67
- | `port` | `number` | Redis port (default: 6379) |
68
- | `password` | `string` | Redis password for authentication |
69
- | `db` | `number` | Redis database number (default: 0) |
70
- | `client` | `RedisClient` | Pre-configured redis client (from the `redis` package) |
71
- | `disableInit` | `boolean` | Disable automatic initialization |
72
-
73
- ## Accessing Storage Domains
74
-
75
- ```typescript
76
- // Access memory domain (threads, messages, resources)
77
- const memory = await storage.getStore('memory');
78
- await memory?.saveThread({ thread });
79
- await memory?.saveMessages({ messages });
80
-
81
- // Access workflows domain
82
- const workflows = await storage.getStore('workflows');
83
- await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
84
-
85
- // Access scores domain
86
- const scores = await storage.getStore('scores');
87
- await scores?.saveScore(score);
88
- ```
89
-
90
- ## Usage with Mastra Agent
91
-
92
- ```typescript
93
- import { Memory } from '@mastra/memory';
94
- import { Agent } from '@mastra/core/agent';
95
- import { RedisStore } from '@mastra/redis';
96
-
97
- export const redisAgent = new Agent({
98
- id: 'redis-agent',
99
- name: 'Redis Agent',
100
- instructions: 'You are an AI agent with memory backed by Redis.',
101
- model: 'openai/gpt-4',
102
- memory: new Memory({
103
- storage: new RedisStore({
104
- id: 'redis-agent-storage',
105
- connectionString: process.env.REDIS_URL!,
106
- }),
107
- options: {
108
- generateTitle: true,
109
- },
110
- }),
111
- });
112
- ```
113
-
114
- ## Accessing the Underlying Client
115
-
116
- You can access the underlying redis client for advanced operations:
117
-
118
- ```typescript
119
- const storage = new RedisStore({
120
- id: 'my-storage',
121
- connectionString: 'redis://localhost:6379',
122
- });
123
-
124
- await storage.init();
125
-
126
- // Get the redis client
127
- const client = storage.getClient();
128
-
129
- // Use for custom operations
130
- await client.set('custom-key', 'value');
131
- const value = await client.get('custom-key');
132
- ```
133
-
134
- ## Key Structure
135
-
136
- The Redis storage uses the following key patterns:
137
-
138
- - Threads: `mastra_threads:id:{threadId}`
139
- - Messages: `mastra_messages:threadId:{threadId}:id:{messageId}`
140
- - Message index: `msg-idx:{messageId}` (for fast lookups)
141
- - Thread messages sorted set: `thread:{threadId}:messages`
142
- - Workflow snapshots: `mastra_workflow_snapshot:namespace:{ns}:workflow_name:{name}:run_id:{id}`
143
- - Scores: `mastra_scorers:id:{scoreId}`
144
- - Resources: `mastra_resources:{resourceId}`
145
-
146
- ## Features
147
-
148
- - Direct Redis connections via the official `redis` package (node-redis)
149
- - Support for Redis Sentinel and Cluster (via custom client)
150
- - Persistent storage for threads, messages, and resources
151
- - Workflow state persistence with snapshot support
152
- - Evaluation scores storage
153
- - Sorted sets for message ordering
154
- - Efficient batch operations with multi/exec
155
-
156
- ## Connection Options
157
-
158
- ### Standalone Redis
159
-
160
- ```typescript
161
- const storage = new RedisStore({
162
- id: 'standalone',
163
- host: 'localhost',
164
- port: 6379,
165
- });
166
- ```
167
-
168
- ### Redis with Password
169
-
170
- ```typescript
171
- const storage = new RedisStore({
172
- id: 'auth',
173
- connectionString: 'redis://:password@localhost:6379',
174
- });
175
- ```
176
-
177
- ### Redis Sentinel (via custom client)
178
-
179
- ```typescript
180
- import { createClient } from 'redis';
181
-
182
- const client = createClient({
183
- url: 'redis://localhost:26379',
184
- // Configure sentinel options as needed
185
- });
186
- await client.connect();
187
-
188
- const storage = new RedisStore({
189
- id: 'sentinel',
190
- client,
191
- });
192
- ```
193
-
194
- ### Redis Cluster (via custom client)
13
+ Configure the database credentials required by your provider.
195
14
 
196
15
  ```typescript
197
16
  import { RedisStore } from '@mastra/redis';
@@ -208,16 +27,14 @@ const storage = new RedisStore({
208
27
  });
209
28
  ```
210
29
 
211
- ## Closing Connections
30
+ ## Documentation
212
31
 
213
- Always close connections when done:
32
+ - [Redis](https://mastra.ai/integrations/databases/redis)
214
33
 
215
- ```typescript
216
- await storage.close();
217
- ```
34
+ ## Changelog
35
+
36
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/redis/CHANGELOG.md) for version history and release notes.
218
37
 
219
- ## Related Links
38
+ ## Support
220
39
 
221
- - [Redis Documentation](https://redis.io/documentation)
222
- - [node-redis Documentation](https://github.com/redis/node-redis)
223
- - [Mastra Documentation](https://mastra.ai/docs)
40
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -3,7 +3,7 @@ name: mastra-redis
3
3
  description: Documentation for @mastra/redis. Use when working with @mastra/redis APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/redis"
6
- version: "1.4.3-alpha.0"
6
+ version: "1.4.3-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.3-alpha.0",
2
+ "version": "1.4.3-alpha.1",
3
3
  "package": "@mastra/redis",
4
4
  "exports": {},
5
5
  "modules": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/redis",
3
- "version": "1.4.3-alpha.0",
3
+ "version": "1.4.3-alpha.1",
4
4
  "description": "Redis storage provider for Mastra - provides storage capabilities for direct Redis connections",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,10 +34,10 @@
34
34
  "tsx": "^4.23.1",
35
35
  "typescript": "^7.0.2",
36
36
  "vitest": "4.1.10",
37
- "@internal/lint": "0.0.129",
38
- "@mastra/core": "1.64.0-alpha.2",
39
37
  "@internal/storage-test-utils": "0.0.125",
40
- "@internal/types-builder": "0.0.104"
38
+ "@internal/types-builder": "0.0.104",
39
+ "@internal/lint": "0.0.129",
40
+ "@mastra/core": "1.64.0-alpha.7"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@mastra/core": ">=1.61.0-0 <2.0.0-0"