deno-redis
概要
基本
connect()
関数で
Redisサーバへ接続できます
接続に成功すると、 Redis
オブジェクトを返却します
typescriptimport { connect } from "https://deno.land/x/redis@v0.11.1/mod.ts"; // v0.11.1の部分は適宜変えてください
const redis = await connect({
hostname: "127.0.0.1",
port: 6379
});
console.log(await redis.get("test"));
APIについて
ioredis同様、ほとんどのメソッドは
Promise
を返却するよう設計されています🙆
Pub/Sub
typescriptconst subscription = await redis.subscribe("channel");
(async () => {
for await (const { channel, message } of subscription.receive()) {
handleMessage(message);
}
})();