diff --git a/packages/plugins/response-cache-redis/src/redis-cache.ts b/packages/plugins/response-cache-redis/src/redis-cache.ts index 3b8f111778..487390033c 100644 --- a/packages/plugins/response-cache-redis/src/redis-cache.ts +++ b/packages/plugins/response-cache-redis/src/redis-cache.ts @@ -70,7 +70,7 @@ export const createRedisCache = (params: RedisCacheParameter): Cache => { pipeline.set(responseId, JSON.stringify(result)); } else { // set the ttl in milliseconds - pipeline.set(responseId, JSON.stringify(result), 'PX', ttl); + pipeline.set(responseId, JSON.stringify(result), 'EX', ttl); } const responseKey = buildRedisOperationResultCacheKey(responseId); diff --git a/packages/plugins/response-cache-redis/test/response-redis-cache.spec.ts b/packages/plugins/response-cache-redis/test/response-redis-cache.spec.ts index 59fbaad47e..53f8b96725 100644 --- a/packages/plugins/response-cache-redis/test/response-redis-cache.spec.ts +++ b/packages/plugins/response-cache-redis/test/response-redis-cache.spec.ts @@ -797,8 +797,8 @@ describeIf(versionInfo.major >= 16)('useResponseCache with Redis cache', () => { // so queried just once expect(spy).toHaveBeenCalledTimes(1); - // let's travel in time beyond the ttl of 100 - jest.advanceTimersByTime(150); + // let's travel in time beyond the ttl of 100 seconds + jest.advanceTimersByTime(150_000); // since the cache has expired, now when we query await testInstance.execute(query); @@ -1083,8 +1083,8 @@ describeIf(versionInfo.major >= 16)('useResponseCache with Redis cache', () => { await testInstance.execute(query); expect(spy).toHaveBeenCalledTimes(1); - // wait so User expires - jest.advanceTimersByTime(201); + // wait so User expires, beyond 200 seconds + jest.advanceTimersByTime(201_000); await testInstance.execute(query); // now we've queried twice @@ -1174,8 +1174,8 @@ describeIf(versionInfo.major >= 16)('useResponseCache with Redis cache', () => { await testInstance.execute(query); expect(spy).toHaveBeenCalledTimes(1); - // wait so User expires - jest.advanceTimersByTime(201); + // wait so User expires beyond 200 seconds + jest.advanceTimersByTime(201_000); await testInstance.execute(query); // now we've queried twice