r2d2
Lightweight Redis client library for Deno. Design principles:
- Must be fundamentally simple
- Use native Deno APIs and Deno's standard library without custom interfaces
- Encourage use of actual Redis commands without intermediate abstractions
Usage
Must be run with --allow-net
permission.
Basic commands
import { sendCommand } from "https://deno.land/x/r2d2/mod.ts";
const redisConn = await Deno.connect({ port: 6379 }); // Connect to the Redis server
await sendCommand(redisConn, ["SET", "hello", "world"]); // Returns "OK"
await sendCommand(redisConn, ["GET", "hello"]); // Returns "world"
redisConn.close(); // Close the connection to the Redis server
If you'd like to ignore the reply.
await sendCommand(redis, ["SHUTDOWN"], false); // Returns nothing
Pipelining
import { pipelineCommands } from "https://deno.land/x/r2d2/mod.ts";
const redisConn = await Deno.connect({ port: 6379 }); // Connect to the Redis server
await pipelineCommands(redisConn, [
["INCR", "X"],
["INCR", "X"],
["INCR", "X"],
["INCR", "X"],
]); // Returns [1, 2, 3, 4]
Documentation
Check out the documentation here.
Testing
deno task test
Note: Redis must be installed on your local machine. For installation instructions, see here.
Benchmarks
deno task bench
Note: Redis must be installed on your local machine. For installation instructions, see here.
Related
- redis - 🦕 Redis client for Deno 🍕