fix(cache): Redis ストアを Keyv アダプタへ切り替え(cache-manager v7 対応) - #36
Merged
Merged
Conversation
検証コードが Redis に保存されず、ログイン・登録の E2E が全件タイムアウトする不具合を修正。
原因: cache-manager v7 は内部で Keyv を使うため stores: Keyv[] を要求するが、cache-manager-redis-store v3 は Keyv 以前の旧インターフェース実装だった。そのため cacheManager.set は成功を返すのに実 Redis には一切書き込まれない(サイレント失敗)状態だった。
- app.module.ts: store: redisStore を stores: [createKeyv({url, password})] に置き換え
- package.json: cache-manager-redis-store と @types/cache-manager-redis-store を削除し @keyv/redis を追加
- TTL はミリ秒のまま(Keyv 実測で 5000 -> pttl 4999ms)。既存の 300*1000 = 5 分は意図どおり
youdingtianzhaogeyinzuo
approved these changes
Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
検証コードが Redis に保存されず、ログイン・登録の E2E が全件タイムアウトする不具合を修正します。
症状
200 验证码发送成功を返す保存验证码: 139xxxx - 654321をログ出力するTimed out waiting for verification codeで全件失敗する原因
cache-managerv7 は内部で Keyv を使うため、stores: Keyv[]を要求します。一方cache-manager-redis-storev3 は Keyv 以前の旧インターフェース実装です。そのため
cacheManager.set()は例外を出さずに成功を返すものの、実 Redis には一切書き込まれません(サイレント失敗)。実測(ローカル):
cache.get"654321"(インメモリから返る)"654321"getnull{"value":"654321",...}dbsize01keys '*'[]["verification_code:..."]補足:
cache-manager-redis-storeの最新版は 3.0.1(2022-10 公開)で、v4 系は存在しません(npm view cache-manager-redis-store@4→ E404)。v7 世代に追随していないため、このパッケージでは解決できません。変更
src/app.module.tscreateKeyvは@keyv/redisの公式ファクトリですttlはミリ秒のまま(Keyv 実測で5000を渡すとpttl 4999になることを確認)package.jsoncache-manager-redis-store,@types/cache-manager-redis-store@keyv/redis@nestjs/cache-manager@3.0.1はcache-manager >=6を要求するため、そのままで整合します(ダウングレード不要)。検証
npx tsc --noEmitnpm run lint:checknpm test -- --runInBand影響範囲
blacklist:*)も同じ経路で書き込まれていました。本修正でそちらも実際に機能するようになりますcacheManagerを使う箇所(health チェック、users サービス)も同一ストアを共有します補足
master不在の checkout 失敗、Playwright キャッシュ誤ヒット、continue-on-error: true)の下に隠れていたものです