fix(cache): back the response cache with Redis on cache-manager v7#108
Merged
Conversation
The cache module was copied from das-gittensor (@nestjs/cache-manager v2 / cache-manager v5). das-github-mirror is on v3 / cache-manager v7 (Keyv-based), where the config shape changed, so the copied config was broken on arrival in b771271: - v3 reads the store list from `stores` (plural Keyv instances); the singular `store` key was ignored, so Redis was never used. - v3 reads the entry TTL from top-level `ttl`; the `ttl` nested inside `redisStore({ ttl })` never reached the cache. Production therefore ran an in-memory cache with no expiry — GET responses were pinned from process start and served stale until the next restart (~20h stale observed on /api/v1/miners/:id/issues). - Replace cache-manager-redis-yet (v5-era, incompatible with v7) with @keyv/redis. - Pass `stores: [Keyv]` + top-level `ttl`. - Namespace cache keys `apicache`, clear of BullMQ's `bull:*`. - Add a store error listener so a Redis blip degrades to an uncached request instead of crashing the process. - Type the factory return as CacheModuleOptions (was `any`).
The previous commit's lockfile was generated with npm 11 (local), which CI's npm 10 (Node 20) rejected as out of sync — `npm ci` reported the chokidar subtree missing from the lock. Regenerated with npm 10 so the lockfile format matches CI; `npm ci` now passes locally under npm 10.
entrius
approved these changes
May 17, 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.
Summary
The response cache module was copied from das-gittensor, which runs
@nestjs/cache-managerv2 /cache-managerv5. das-github-mirror is on v3 /cache-managerv7 (Keyv-based), where the config shape changed — so the copied config was silently broken on arrival (commitb771271):stores(plural, Keyv instances). The singularstorekey was ignored, so Redis was never used.ttl. Thettlnested insideredisStore({ ttl })never reached the cache.Net effect in production: an in-memory cache with no expiry. Cached GET responses were pinned from process start and served stale until the next restart — observed ~20h stale on
/api/v1/miners/:id/issues.This PR:
cache-manager-redis-yet(v5-era, incompatible with cache-manager v7) with@keyv/redis, the Keyv-era Redis adapter.stores: [Keyv]+ top-levelttl— the shape v3 actually reads.apicacheto stay clear of BullMQ'sbull:*keyspace on the shared Redis instance.errorlistener so a Redis outage degrades to an uncached request instead of crashing the process on an unhandledEventEmittererror.CacheModuleOptionsinstead ofany— the type hole that let the wrong shape compile silently.Related Issues
None.
Type of Change
Testing
npm run build— passesnpx eslint/prettier --check— clean@keyv/rediswiring (stores: [Keyv],apicachenamespace)Checklist
−cache-manager-redis-yet,+@keyv/redis(the correct adapter for the installedcache-managerversion)Note
This fixes the application cache only. A reverse-proxy cache fronting
mirror.gittensor.io(thex-cacheresponse header) is a separate layer outside this repo and should be checked independently.