Description
The backend has two separate Redis connection managers that create independent connections to the same Redis instance, wasting resources and causing silent cache failures.
Locations
backend/src/services/redisService.js β Creates one Redis client with memory fallback
backend/src/services/cacheService.js β Creates a second Redis client to localhost:6379
Issues
cacheService.js has its own Redis client connecting to localhost:6379 independently
cacheService.initialize() is never called in server.js, so it remains perpetually disconnected
- Multiple files import
cacheService.js (compileService.js, cacheInterceptor.js, various middleware) expecting it to work, but all cache operations silently fail
- The
compileService.js explicitly stubs out cache functions as no-ops because of this:
async function storeCacheEntry(_entry) { /* no-op */ }
async function invalidateCache(_opts) { /* no-op */ }
Impact
- Compilation cache is supposed to persist using Redis but instead relies solely on in-memory LRU
- LRU cache is lost on server restart, forcing recompilation of all contracts
- All search/facet/autocomplete caching silently fails
- Two connections to Redis when only one is needed
Required Fix
- Merge
cacheService.js functionality into redisService.js or eliminate the duplicate
- Replace compileService stub cache functions with real implementations using
redisService
- Call
cacheService.initialize() in server startup if keeping it separate
Reference
Identified during full codebase audit of soroban-playground.
Description
The backend has two separate Redis connection managers that create independent connections to the same Redis instance, wasting resources and causing silent cache failures.
Locations
backend/src/services/redisService.jsβ Creates one Redis client with memory fallbackbackend/src/services/cacheService.jsβ Creates a second Redis client to localhost:6379Issues
cacheService.jshas its own Redis client connecting tolocalhost:6379independentlycacheService.initialize()is never called inserver.js, so it remains perpetually disconnectedcacheService.js(compileService.js, cacheInterceptor.js, various middleware) expecting it to work, but all cache operations silently failcompileService.jsexplicitly stubs out cache functions as no-ops because of this:Impact
Required Fix
cacheService.jsfunctionality intoredisService.jsor eliminate the duplicateredisServicecacheService.initialize()in server startup if keeping it separateReference
Identified during full codebase audit of soroban-playground.