mcpField
I
ioredis

ioredis

github.com/jgamaraalv開発1557 回インストール35 週間前に更新
リポジトリ

ioredis について

ioredis v5 を使う開発者向けのリファレンススキルです。TypeScript の Redis クライアントの基本操作、接続設定、高度なパターンを扱います。

主な機能

  1. 01Redis 接続の設定
  2. 02パイプラインとトランザクション
  3. 03Pub/Sub と Lua スクリプト
  4. 04スキャンとストリームのパターン
  5. 05Cluster と Sentinel の設定ガイド

活用シーン

  1. 01Redis 接続のセットアップ
  2. 02複数コマンド操作のパターン選択
  3. 03Pub/Sub や Lua スクリプトの利用
  4. 04Redis Cluster または Sentinel の設定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/jgamaraalv/ts-dev-kit --skill ioredis

インストール後、Claude Code で/ioredisを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
advanced-patterns.md
cluster-sentinel.md
connection-options.md
core-api.md

詳細

ioredis v5 — Node.js Redis クライアント

ioredis v5.x。Node.js >= 12、Redis >= 2.6.12 が必要です。100% TypeScript です。

<quick_reference>

重要:インポート形式

// CORRECT — named import (required for NodeNext / moduleResolution: "nodenext")
import { Redis } from "ioredis";

// For Cluster:
import { Redis, Cluster } from "ioredis";

クイックリファレンス

操作コード
接続new Redis() または new Redis(6379, "host") または new Redis("redis://...")
取得/設定await redis.set("key", "val") / await redis.get("key")
パイプラインawait redis.pipeline().set("a","1").get("a").exec()
トランザクションawait redis.multi().set("a","1").get("a").exec()
Pub/Subsub.subscribe("ch") / sub.on("message", cb) / pub.publish("ch", msg)
Lua スクリプトredis.defineCommand("name", { numberOfKeys: 1, lua: "..." })
スキャンredis.scanStream({ match: "prefix:*", count: 100 })
正常な切断await redis.quit()
強制切断redis.disconnect()

</quick_reference>

よくある注意点

  1. 名前付きインポート:NodeNext 解決を使用する場合は、必ず import { Redis } from "ioredis" を使用してください
  2. Pub/Sub の分離:サブスクライブ中のクライアントでは他のコマンドを実行できません。別のインスタンスを使用してください
  3. maxRetriesPerRequest:デフォルトは 20 です。無限に再試行するには null を設定してください(BullMQ で必須)
  4. パイプラインのエラー:pipeline.exec() は決して reject しません。エラーは各結果の [0] の位置に格納されます
  5. showFriendlyErrorStack:パフォーマンスコストがかかるため、本番環境では有効にしないでください
  6. クラスターのパイプライン:パイプライン内のすべてのキーは、同じノードが処理するスロットにハッシュされる必要があります
  7. enableAutoPipelining:スループットが 35~50% 向上します。グローバルに有効にしても安全です

リファレンスの読み込みタイミング

必要な情報リファレンスファイル
接続のセットアップ、RedisOptions、TLS、retryStrategy、ライフサイクルreferences/connection-options.md
コア API:パイプライン、トランザクション、Pub/Sub、Lua スクリプト、スキャン、イベントreferences/core-api.md
ストリーム、自動パイプライン、トランスフォーマー、バイナリデータ、エラー処理、デバッグreferences/advanced-patterns.md
Redis Cluster のセットアップ、ClusterOptions、Sentinel の設定、フェイルオーバーreferences/cluster-sentinel.md

コメント