Skip to content

Commit 85829a4

Browse files
fix: r2d2 has been moved to @iuioiua/redis (#1566)
Co-authored-by: Jo Franchetti <[email protected]>
1 parent 607c84c commit 85829a4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

examples/scripts/redis.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33
* @difficulty intermediate
44
* @tags cli, deploy
55
* @run --allow-net --allow-env <url>
6-
* @resource {https://deno.land/x/r2d2} r2d2 on deno.land/x
6+
* @resource {https://jsr.io/@iuioiua/redis} redis on jsr.io
77
* @resource {https://redis.io/docs/getting-started/} Getting started with Redis
88
* @group Databases
99
*
10-
* Using the r2d2 module, you can connect to a Redis database running anywhere.
10+
* Using the jsr:@iuioiua/redis module, you can connect to a Redis database running anywhere.
1111
*/
1212

13-
// Import the `sendCommand()` function from r2d2
14-
import { sendCommand } from "https://deno.land/x/r2d2/mod.ts";
13+
// Import the `RedisClient` from jsr:@iuioiua/redis
14+
import { RedisClient } from "jsr:@iuioiua/redis";
1515

1616
// Create a TCP connection with the Redis server
17-
const redisConn = await Deno.connect({ port: 6379 });
17+
using redisConn = await Deno.connect({ port: 6379 });
18+
19+
// Create an instance of 'RedisClient'
20+
const redisClient = new RedisClient(redisConn);
1821

1922
// Authenticate with the server by sending the command "AUTH <username> <password>"
20-
await sendCommand(redisConn, [
23+
await redisClient.sendCommand([
2124
"AUTH",
2225
Deno.env.get("REDIS_USERNAME")!,
2326
Deno.env.get("REDIS_PASSWORD")!,
2427
]);
2528

2629
// Set the "hello" key to have value "world" using the command "SET hello world"
27-
await sendCommand(redisConn, ["SET", "hello", "world"]); // "OK"
30+
await redisClient.sendCommand(["SET", "hello", "world"]); // "OK"
2831

2932
// Get the "hello" key using the command "GET hello"
30-
await sendCommand(redisConn, ["GET", "hello"]); // "world"
31-
32-
// Close the connection to the database
33-
redisConn.close();
33+
await redisClient.sendCommand(["GET", "hello"]); // "world"

0 commit comments

Comments
 (0)