Type caches

This commit is contained in:
Adria Navarro 2024-03-01 11:04:55 +01:00
parent 8062c28722
commit cd56e1ffff
1 changed files with 3 additions and 3 deletions

View File

@ -58,12 +58,12 @@ export default class BaseCache {
/**
* Read from the cache. Write to the cache if not exists.
*/
async withCache(
async withCache<T>(
key: string,
ttl: number | null = null,
fetchFn: any,
fetchFn: () => Promise<T> | T,
opts = { useTenancy: true }
) {
): Promise<T> {
const cachedValue = await this.get(key, opts)
if (cachedValue) {
return cachedValue