@soundxyz/fine-grained-cache
Advanced tools
Comparing version 2.3.1 to 2.4.0
@@ -38,3 +38,3 @@ import type { Redis } from "ioredis"; | ||
}; | ||
export type Events = typeof Events[keyof typeof Events]; | ||
export type Events = (typeof Events)[keyof typeof Events]; | ||
export type EventParamsObject = Record<string, string | number | boolean | null | undefined>; | ||
@@ -133,3 +133,3 @@ export type LogEventArgs = { | ||
invalidateCache: (keys_0: string, ...keys_1: (string | number)[]) => Promise<void>; | ||
setCache: ({ populateMemoryCache, ttl, keys, useSuperjson, value, }: { | ||
setCache: <T_1 = unknown>({ populateMemoryCache, ttl, keys, useSuperjson, value, }: { | ||
populateMemoryCache: boolean; | ||
@@ -139,5 +139,15 @@ ttl: StringValue | "Infinity"; | ||
useSuperjson: boolean; | ||
value: unknown; | ||
value: T_1; | ||
}) => Promise<void>; | ||
readCache: <T_2 = unknown>({ keys, useSuperjson, }: { | ||
keys: string | [string, ...(string | number)[]]; | ||
useSuperjson: boolean; | ||
}) => Promise<{ | ||
readonly found: false; | ||
readonly value?: undefined; | ||
} | { | ||
readonly found: true; | ||
readonly value: Awaited<T_2>; | ||
}>; | ||
}; | ||
export {}; |
@@ -563,2 +563,19 @@ 'use strict'; | ||
} | ||
function readCache({ | ||
keys, | ||
useSuperjson | ||
}) { | ||
const key = generateCacheKey(keys); | ||
return getRedisCacheValue(key, useSuperjson, false).then((value) => { | ||
if (value === NotFoundSymbol) { | ||
return { | ||
found: false | ||
}; | ||
} | ||
return { | ||
found: true, | ||
value | ||
}; | ||
}); | ||
} | ||
return { | ||
@@ -570,3 +587,4 @@ getCached, | ||
invalidateCache, | ||
setCache | ||
setCache, | ||
readCache | ||
}; | ||
@@ -573,0 +591,0 @@ } |
{ | ||
"name": "@soundxyz/fine-grained-cache", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "Fine-grained cache helper using redis", | ||
@@ -41,3 +41,3 @@ "keywords": [ | ||
"@types/node": "^18.11.18", | ||
"ava": "^5.1.0", | ||
"ava": "^5.1.1", | ||
"bob-ts": "^4.1.1", | ||
@@ -56,3 +56,3 @@ "bob-tsm": "^1.1.2", | ||
"peerDependencies": { | ||
"ioredis": "^5.0.6", | ||
"ioredis": "^5.2.4", | ||
"redlock": "5.0.0-beta.2" | ||
@@ -59,0 +59,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50607
1445