@soundxyz/fine-grained-cache
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -10,3 +10,3 @@ import type { Redis } from "ioredis"; | ||
} | ||
export declare type CachedCallback<T> = (options: { | ||
export type CachedCallback<T> = (options: { | ||
setTTL(options: { | ||
@@ -39,5 +39,5 @@ /** | ||
}; | ||
export declare type Events = typeof Events[keyof typeof Events]; | ||
export declare type EventParamsObject = Record<string, string | number | boolean | null | undefined>; | ||
export declare type LogEventArgs = { | ||
export type Events = typeof Events[keyof typeof Events]; | ||
export type EventParamsObject = Record<string, string | number | boolean | null | undefined>; | ||
export type LogEventArgs = { | ||
message: string; | ||
@@ -47,3 +47,3 @@ code: Events; | ||
}; | ||
export declare type LoggedEvents = Partial<Record<Events, string | boolean | null | ((args: LogEventArgs) => void)>>; | ||
export type LoggedEvents = Partial<Record<Events, string | boolean | null | ((args: LogEventArgs) => void)>>; | ||
export declare function FineGrainedCache({ redis, redLock: redLockConfig, keyPrefix, memoryCache, onError, logEvents, GETRedisTimeout, pipelineRedisGET, pipelineRedisSET, defaultUseMemoryCache, awaitRedisSet, }: { | ||
@@ -50,0 +50,0 @@ redis: Redis; |
@@ -238,2 +238,12 @@ 'use strict'; | ||
} | ||
let currentTimeout = null; | ||
function timeoutRedisPromise() { | ||
if (currentTimeout) | ||
return currentTimeout; | ||
currentTimeout = promises.setTimeout(GETRedisTimeout, void 0); | ||
setTimeout(() => { | ||
currentTimeout = null; | ||
}); | ||
return currentTimeout; | ||
} | ||
async function getRedisCacheValue(key, useSuperjson, checkShortMemoryCache) { | ||
@@ -260,3 +270,3 @@ const tracing = enabledLogEvents?.REDIS_GET || enabledLogEvents?.REDIS_GET_TIMED_OUT ? getTracing() : null; | ||
); | ||
const redisValue = await (GETRedisTimeout != null ? Promise.race([redisGet, promises.setTimeout(GETRedisTimeout, void 0)]) : redisGet); | ||
const redisValue = await (GETRedisTimeout != null ? Promise.race([redisGet, timeoutRedisPromise()]) : redisGet); | ||
if (redisValue === void 0) { | ||
@@ -263,0 +273,0 @@ timedOut = true; |
{ | ||
"name": "@soundxyz/fine-grained-cache", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Fine-grained cache helper using redis", | ||
@@ -34,21 +34,21 @@ "keywords": [ | ||
"dependencies": { | ||
"lru-cache": "^7.14.0", | ||
"lru-cache": "^7.14.1", | ||
"ms": "3.0.0-canary.1", | ||
"superjson": "^1.10.0" | ||
"superjson": "^1.12.1" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.24.4", | ||
"@types/node": "^18.7.23", | ||
"ava": "^4.3.3", | ||
"@changesets/cli": "^2.26.0", | ||
"@types/node": "^18.11.18", | ||
"ava": "^5.1.0", | ||
"bob-ts": "^4.1.1", | ||
"bob-tsm": "^1.1.2", | ||
"c8": "^7.12.0", | ||
"concurrently": "^7.4.0", | ||
"concurrently": "^7.6.0", | ||
"date-fns": "^2.29.3", | ||
"esbuild": "^0.15.9", | ||
"esbuild": "^0.16.17", | ||
"execa": "^6.1.0", | ||
"ioredis": "^5.2.3", | ||
"prettier": "^2.7.1", | ||
"ioredis": "^5.2.4", | ||
"prettier": "^2.8.2", | ||
"redlock": "5.0.0-beta.2", | ||
"typescript": "^4.8.4" | ||
"typescript": "^4.9.4" | ||
}, | ||
@@ -55,0 +55,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
49567
1399
Updatedlru-cache@^7.14.1
Updatedsuperjson@^1.12.1