@@ -50,8 +50,8 @@ On this page, you will find information on how to create, configure, and connect
50
50
- Once the data store is created, clicking the data store row will open a drawer with the data store configuration,
51
51
including the auto-generated passkey and a Redis-compatible ** Connection URI** .
52
52
- Once the data store's ** Status** becomes ** Active** , you can try accessing it with Redis CLI,
53
- for instance, ` redis-cli -u <Connection_URI > PING ` .
54
- Read more information on [ how to connect to the data store] ( #connecting-to-data-store ) below.
53
+ for instance, ` redis-cli -u <CONNECTION_URI > PING ` .
54
+ Read more information on [ how to connect to the data store] ( #connecting-to-a- data-store ) below.
55
55
56
56
### Updating the Data Store Configuration
57
57
@@ -152,113 +152,118 @@ in our blog posts.
152
152
153
153
---
154
154
155
- ## Connecting to Data Store
155
+ ## Connecting to a Data Store
156
156
157
- Once a data store * Status* is * Active* you can connect to it with any Redis client using the * Connection URI* provided
158
- in the data store drawer (e.g. rediss://default: h6blm92XXXsa @52tyg3xkp .dragonflydb.cloud:6385).
159
- Here are a few popular examples:
157
+ Once a data store's ** Status** is ** Active** , you can connect to it with any Redis client using the ** Connection URI**
158
+ provided in the data store drawer (e.g., ` rediss://default:XXXXX@abcde .dragonflydb.cloud:6385 ` ).
159
+ Here are a few popular client libraries and code snippets to connect to the data store.
160
160
161
161
### Redis CLI
162
162
163
- 1 . Install redis-cli, ` sudo apt install redis-tools `
164
- 2 . With the * Connection URI* from the data store drawer execute redis-cli in the terminal e.g.
165
- ` redis-cli -u <connection URI> PING `
163
+ - Install [ ` redis-cli ` ] ( https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/ ) .
164
+ - With the ** Connection URI** from the data store drawer, execute ` redis-cli ` in the terminal:
166
165
167
- ### Node.js
166
+ ``` shell
167
+ $> redis-cli -u < CONNECTION_URI> PING
168
+ ```
168
169
169
- 1 . Install the redis npm package, ` npm install redis `
170
- 2 . Use the following code snippet to connect to the data store
170
+ ### JavaScript | Typescript | Node.js
171
171
172
- ``` javascript
173
- import { createClient } from ' redis ' ;
172
+ - Install the [ ` ioredis ` ] ( https://github.com/redis/ioredis ) package.
173
+ - Use the following code snippet to connect to the data store:
174
174
175
- const client = createClient ({url : ' <connection URI> ' });
176
- client . on ( ' connect ' , () => {
177
- console . log ( ' Connected to Redis ' );
178
- });
179
- client . on ( ' error ' , ( err ) => {
180
- console . error ( ' Redis error ' , err);
181
- });
182
- client . ping (( err , res ) => {
183
- if (err) {
184
- console . error ( ' Error: ' , err);
185
- return ;
186
- }
187
- console . log ( ' Redis PING: ' , res);
175
+ ``` javascript
176
+ const Client = require ( " ioredis " );
177
+
178
+ // Using connection URI directly.
179
+ const client = new Client ( " <CONNECTION_URI> " );
180
+
181
+ // Using connection options.
182
+ const client2 = new Client ( {
183
+ port : 6385 ,
184
+ host : " abcde.dragonflydb.cloud " ,
185
+ username : " default " ,
186
+ password : " XXXXX " ,
187
+ db : 0 ,
188
188
});
189
189
190
+ client .ping ();
190
191
```
191
192
192
193
### Python
193
194
194
- 1 . Install the redis-py package, ` pip install redis `
195
- 2 . Use the following code snippet to connect to the data store
195
+ - Install the [ redis-py] ( https://github.com/redis/redis-py ) package.
196
+ - Use the following code snippet to connect to the data store:
196
197
197
198
``` python
198
199
import redis
199
- client = redis.Redis.from_url(' <connection URI>' )
200
+
201
+ client = redis.Redis.from_url(' <CONNECTION_URI>' )
200
202
client.ping()
201
203
```
202
204
203
205
### Go
204
206
205
- 1 . Install the go-redis package, ` go get github.com/go-redis/redis/v8 `
206
- 2 . Use the following code snippet to connect to the data store
207
+ - Install the [ go-redis] ( https:// github.com/redis/ go-redis) package.
208
+ - Use the following code snippet to connect to the data store:
207
209
208
210
``` go
209
211
package main
210
212
211
213
import (
212
- " fmt"
214
+ " fmt"
215
+
213
216
" github.com/go-redis/redis/v8"
214
217
)
215
218
216
219
func main () {
217
- // Replace "<connection URI>" with the actual connection URI,
218
- // <db> is the database number, default is 0
219
- opt , err := redis.ParseURL (" <connection URI>/<db>" )
220
- if err != nil {
221
- panic (err)
222
- }
223
-
224
- client := redis.NewClient (opt)
225
-
226
- pong , err := client.Ping (client.Context ()).Result ()
227
- if err != nil {
228
- fmt.Println (" Error:" , err)
229
- return
230
- }
231
-
232
- fmt.Println (" Connected to Redis:" , pong)
220
+ // Replace "<CONNECTION_URI>" with the actual connection URI.
221
+ // Note that <db> is the database number and its default value is 0.
222
+ opts , err := redis.ParseURL (" <CONNECTION_URI>/<db>" )
223
+ if err != nil {
224
+ panic (err)
225
+ }
226
+
227
+ client := redis.NewClient (opts)
228
+
229
+ pong , err := client.Ping (client.Context ()).Result ()
230
+ if err != nil {
231
+ fmt.Println (err)
232
+ }
233
+
234
+ fmt.Println (pong)
233
235
}
234
236
```
235
237
236
238
## ACL Rules
237
239
238
- You can leverage [ Dragonfly's built in support for ACLs] ( https://www.dragonflydb.io/docs/managing-dragonfly/acl ) with
239
- Dragonfly Cloud.
240
+ You can leverage [ Dragonfly's built-in support for ACLs] ( https://www.dragonflydb.io/docs/category/acl ) to control access
241
+ to your data stores within Dragonfly Cloud. Each Dragonfly Cloud data store is created with a default ACL rule
242
+ that allows all commands for the ` default ` user:
240
243
241
- Each Dragonfly Cloud data store is created with a default ACL rule that allows all commands for the default user.
242
- ` USER default ON >pmn4p0ssrbbl ~* +@ALL `
244
+ ``` text
245
+ USER default ON >pmn4p0ssrbbl ~* +@ALL
246
+ ```
243
247
244
- To modify the data store ACL rules, click the data store three-dot
245
- menu (<svg xmlns =" http://www.w3.org/2000/svg " height =" 24px " viewBox =" 0 -960 960 960 " width =" 24px " fill =" #e8eaed " ><path d =" M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z " /></svg >)
246
- and click * Acl Rules*
247
- An ACL Rules editor drawer will open where you can add, modify or delete ACL rules.
248
+ - To modify the data store ACL rules, click the data store three-dot
249
+ menu (<svg xmlns =" http://www.w3.org/2000/svg " height =" 24px " viewBox =" 0 -960 960 960 " width =" 24px " fill =" #e8eaed " ><path d =" M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z " /></svg >)
250
+ and click ** ACL Rules** .
251
+ - An editor drawer for ACL rules will open where you can add, modify, or delete ACL rules.
252
+ - *** CAUTION: Altering ACL rules can potentially disrupt access for current users. It is always recommended to test ACL
253
+ rules on a test data store before applying them to a production data store.***
248
254
249
- *** Caution:*** Altering ACL rules can potentially disrupt access for current users. It is always recommended to test ACL
250
- rules on a test data store before applying them to a production data store.
255
+ ### Rotating Data Store Passkey
251
256
252
- ### How to rotate data store passkey
257
+ Here is a recipe to rotate the passkey for a data store, since it is part of the ACL rules:
253
258
254
- 1 . Modify the default ACL rule to e.g. ` USER default ON >pmn4p0ssrbbl >mynewpass ~* +@ALL `
255
- 2 . Verify you can now authenticate with both pmn4p0ssrbbl ( old passkey) and mynewpass ( new passkey)
256
- 3 . Migrate all consumers to authenticate with the new passkey
257
- 4 . Modify the default ACL rule to only include the new passkey e.g. ` USER default ON >mynewpass ~* +@ALL `
258
- 5 . Verify you can no longer authenticate with the old passkey.
259
- 6 . *** Caution: *** It is always recommended to test ACL rules on a test data store before applying them to a production
260
- data store.
259
+ - Modify the default ACL rule to something like: ` USER default ON >myoldpass >mynewpass ~* +@ALL ` .
260
+ - Verify you can now authenticate with both the old and new passkeys.
261
+ - Migrate all consumers to authenticate with the new passkey.
262
+ - Modify the default ACL rule to only include the new passkey: ` USER default ON >mynewpass ~* +@ALL ` .
263
+ - Verify you can no longer authenticate with the old passkey.
264
+ - *** CAUTION: Altering ACL rules can potentially disrupt access for current users. It is always recommended to test ACL
265
+ rules on a test data store before applying them to a production data store. ***
261
266
262
267
## Support Plans
263
268
264
- See more information on support plans [ here] ( ./support.md ) .
269
+ See more information on Dragonfly Cloud support plans [ here] ( ./support.md ) .
0 commit comments