import Redis from 'ioredis';
const cache = redisCache(new Redis('redis://localhost:6379'));
await cache.set('bal:usr_42:spendable', 'CREDIT:12.34', 60_000);
await cache.get('bal:usr_42:spendable'); // 'CREDIT:12.34' | null past the TTL
await cache.close();
Storage for how the cache port backs hot reads.
Adapts an already-connected ioredis client into the Cache the core expects. Values are opaque strings; this adapter never parses them. The caller creates and owns the client (TLS, sentinel, cluster), which also lets a test substitute a fake; the returned
close()releases the connection.ttlMsmaps to Redis'sPXflag, so expiry is enforced by Redis itself; asetwith no TTL persists until invalidated. Keys live under theeconomy:cache:prefix, so they never collide with other data in the instance and an operator can find or delete them as a set. A failed call throws a retryableSTORE.FAILURE; the cache is best-effort, so callers fall back to the store.