{"id":30180611,"url":"https://github.com/keroxp/deno-redis","last_synced_at":"2025-08-12T08:01:59.463Z","repository":{"id":37035683,"uuid":"163508735","full_name":"denodrivers/redis","owner":"denodrivers","description":"🦕 Redis client for Deno 🍕","archived":false,"fork":false,"pushed_at":"2025-08-02T08:48:52.000Z","size":925,"stargazers_count":467,"open_issues_count":40,"forks_count":48,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-11T20:42:34.667Z","etag":null,"topics":["deno","redis"],"latest_commit_sha":null,"homepage":"https://jsr.io/@db/redis","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denodrivers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["keroxp"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-12-29T12:19:02.000Z","updated_at":"2025-08-02T08:48:54.000Z","dependencies_parsed_at":"2023-02-12T15:25:14.097Z","dependency_job_id":"4f887b83-551c-43b8-b37d-160e779adf9a","html_url":"https://github.com/denodrivers/redis","commit_stats":{"total_commits":382,"total_committers":30,"mean_commits":"12.733333333333333","dds":0.4397905759162304,"last_synced_commit":"a1041a52a6e1082281e1189e76d0db5ea333aea4"},"previous_names":["keroxp/deno-redis"],"tags_count":97,"template":false,"template_full_name":null,"purl":"pkg:github/denodrivers/redis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denodrivers%2Fredis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denodrivers%2Fredis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denodrivers%2Fredis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denodrivers%2Fredis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denodrivers","download_url":"https://codeload.github.com/denodrivers/redis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denodrivers%2Fredis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270024697,"owners_count":24514054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","redis"],"created_at":"2025-08-12T08:01:27.631Z","updated_at":"2025-08-12T08:01:59.432Z","avatar_url":"https://github.com/denodrivers.png","language":"TypeScript","funding_links":["https://github.com/sponsors/keroxp"],"categories":["Modules","Uncategorized","基础设施","Libraries"],"sub_categories":["Online Playgrounds","Assistants","Uncategorized","Deno 源"],"readme":"# deno-redis\n\n[![JSR](https://jsr.io/badges/@db/redis)](https://jsr.io/@db/redis)\n[![Build Status](https://github.com/denodrivers/redis/workflows/CI/badge.svg)](https://github.com/denodrivers/redis/actions)\n[![license](https://img.shields.io/github/license/denodrivers/redis.svg)](https://github.com/denodrivers/redis)\n[![Discord](https://img.shields.io/discord/768918486575480863?logo=discord)](https://discord.gg/QXuHBMcgWx)\n\nAn experimental implementation of redis client for deno\n\n## Usage\n\n### Installation\n\n```shell\n$ deno add jsr:@db/redis\n```\n\n### Permissions\n\n`deno-redis` needs `--allow-net` privilege\n\n### Stateless Commands\n\n```ts\nimport { connect } from \"@db/redis\";\nconst redis = await connect({\n  hostname: \"127.0.0.1\",\n  port: 6379,\n});\nconst ok = await redis.set(\"hoge\", \"fuga\");\nconst fuga = await redis.get(\"hoge\");\n```\n\n### Pub/Sub\n\n```ts\nimport { connect } from \"@db/redis\";\n\nconst redis = await connect({ hostname: \"127.0.0.1\" });\nconst sub = await redis.subscribe(\"channel\");\n(async function () {\n  for await (const { channel, message } of sub.receive()) {\n    // on message\n  }\n})();\n```\n\n### Streams\n\n```ts\nimport { connect } from \"@db/redis\";\n\nconst redis = await connect({ hostname: \"127.0.0.1\" });\nawait redis.xadd(\n  \"somestream\",\n  \"*\", // let redis assign message ID\n  { yes: \"please\", no: \"thankyou\" },\n  { elements: 10 },\n);\n\nconst [stream] = await redis.xread(\n  [{ key: \"somestream\", xid: 0 }], // read from beginning\n  { block: 5000 },\n);\n\nconst msgFV = stream.messages[0].fieldValues;\nconst plz = msgFV[\"yes\"];\nconst thx = msgFV[\"no\"];\n```\n\n### Cluster\n\nFirst, if you need to set up nodes into a working redis cluster:\n\n```ts\nimport { connect } from \"@db/redis\";\n\nconst redis = await connect({ hostname: \"127.0.0.1\", port: 6379 });\n\n// connect each node to form a cluster (see https://redis.io/commands/cluster-meet)\nawait redis.clusterMeet(\"127.0.0.1\", 6380);\n// ...\n\n// List the nodes in the cluster\nawait redis.clusterNodes();\n// ... 127.0.0.1:6379@16379 myself,master - 0 1593978765000 0 connected\n// ... 127.0.0.1:6380@16380 master - 0 1593978766503 1 connected\n```\n\nTo consume a redis cluster, you can use\n[experimental/cluster module](experimental/cluster/README.md).\n\n## Advanced Usage\n\n### Handle connection timeout\n\nConnection timeout handling can be implemented with `signal` option:\n\n```ts\nimport { connect } from \"@db/redis\";\n\nusing redis = await connect({\n  hostname: \"127.0.0.1\",\n  signal: () =\u003e AbortSignal.timeout(5_000),\n});\n```\n\n### Retriable connection\n\nBy default, a client's connection will retry a command execution based on\nexponential backoff algorithm if the server dies or the network becomes\nunavailable. You can change the maximum number of retries by setting\n`maxRetryCount` (It's default to `10`):\n\n```ts\nimport { connect } from \"@db/redis\";\n\nconst redis = await connect({ hostname: \"127.0.0.1\", maxRetryCount: 0 }); // Disable retries\n```\n\n### Execute raw commands\n\n`Redis.sendCommand` is low level interface for\n[redis protocol](https://redis.io/topics/protocol). You can send raw redis\ncommands and receive replies.\n\n```ts\nimport { connect } from \"@db/redis\";\n\nconst redis = await connect({ hostname: \"127.0.0.1\" });\n\nconst reply = await redis.sendCommand(\"SET\", [\"redis\", \"nice\"]);\nconsole.assert(reply === \"OK\");\n```\n\nIf `returnUint8Arrays` option is set to `true`, simple strings and bulk strings\nare returned as `Uint8Array`\n\n```ts\nimport { connect } from \"@db/redis\";\n\nconst redis = await connect({ hostname: \"127.0.0.1\" });\n\nconst reply = await redis.sendCommand(\"GET\", [\"redis\"], {\n  returnUint8Arrays: true,\n});\nconsole.assert(reply instanceof Uint8Array);\n```\n\n### Pipelining\n\nhttps://redis.io/topics/pipelining\n\n```ts\nimport { connect } from \"@db/redis\";\n\nconst redis = await connect({ hostname: \"127.0.0.1\" });\nconst pl = redis.pipeline();\npl.ping();\npl.ping();\npl.set(\"set1\", \"value1\");\npl.set(\"set2\", \"value2\");\npl.mget(\"set1\", \"set2\");\npl.del(\"set1\");\npl.del(\"set2\");\nconst replies = await pl.flush();\n```\n\n### TxPipeline (pipeline with MULTI/EXEC)\n\nWe recommend to use `tx()` instead of `multi()/exec()` for transactional\noperation. `MULTI/EXEC` are potentially stateful operation so that operation's\natomicity is guaranteed but redis's state may change between MULTI and EXEC.\n\n`WATCH` is designed for these problems. You can ignore it by using TxPipeline\nbecause pipelined MULTI/EXEC commands are strictly executed in order at the time\nand no changes will happen during execution.\n\nSee detail https://redis.io/topics/transactions\n\n```ts\nimport { connect } from \"@db/redis\";\n\nconst redis = await connect({ hostname: \"127.0.0.1\" });\nconst tx = redis.tx();\ntx.set(\"a\", \"aa\");\ntx.set(\"b\", \"bb\");\ntx.del(\"c\");\nawait tx.flush();\n// MULTI\n// SET a aa\n// SET b bb\n// DEL c\n// EXEC\n```\n\n### Client side caching\n\nhttps://redis.io/topics/client-side-caching\n\n```typescript\nimport { connect } from \"@db/redis\";\n\nconst mainClient = await connect({ hostname: \"127.0.0.1\" });\nconst cacheClient = await connect({ hostname: \"127.0.0.1\" });\n\nconst cacheClientID = await cacheClient.clientID();\nawait mainClient.clientTracking({\n  mode: \"ON\",\n  redirect: cacheClientID,\n});\nconst sub = await cacheClient.subscribe\u003cstring[]\u003e(\"__redis__:invalidate\");\n\n(async () =\u003e {\n  for await (const { channel, message } of sub.receive()) {\n    // Handle invalidation messages...\n  }\n})();\n```\n\n### Connection pooling\n\n\u003e [!WARNING]\n\u003e This feature is still experimental and may change in the future.\n\n`@db/redis/experimental/pool` module provides connection pooling:\n\n```typescript\nimport { createPoolClient } from \"@db/redis/experimental/pool\";\n\nconst redis = await createPoolClient({\n  connection: {\n    hostname: \"127.0.0.1\",\n    port: 6379,\n  },\n});\nawait redis.set(\"foo\", \"bar\");\nawait redis.get(\"foo\");\n```\n\n### Experimental features\n\ndeno-redis provides some experimental features.\n\nSee [experimental/README.md](experimental/README.md) for details.\n\n## Roadmap for v1\n\n- See https://github.com/denodrivers/redis/issues/78\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeroxp%2Fdeno-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeroxp%2Fdeno-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeroxp%2Fdeno-redis/lists"}