From 971ce91ffd1b6bf0a155c2d40f649543c25ef0f8 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Tue, 21 Feb 2023 11:44:29 +0530 Subject: [PATCH] refactor: use NodeCache arg in cacheable signal store --- src/Utils/auth-utils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Utils/auth-utils.ts b/src/Utils/auth-utils.ts index f1f3393..ceffb38 100644 --- a/src/Utils/auth-utils.ts +++ b/src/Utils/auth-utils.ts @@ -1,6 +1,7 @@ import { randomBytes } from 'crypto' import NodeCache from 'node-cache' import type { Logger } from 'pino' +import { DEFAULT_CACHE_TTLS } from '../Defaults' import type { AuthenticationCreds, SignalDataSet, SignalDataTypeMap, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types' import { Curve, signedKeyPair } from './crypto' import { delay, generateRegistrationId } from './generics' @@ -9,15 +10,15 @@ import { delay, generateRegistrationId } from './generics' * Adds caching capability to a SignalKeyStore * @param store the store to add caching to * @param logger to log trace events - * @param opts NodeCache options + * @param _cache NodeCache to use */ export function makeCacheableSignalKeyStore( store: SignalKeyStore, logger: Logger, - opts?: NodeCache.Options + _cache?: NodeCache ): SignalKeyStore { - const cache = new NodeCache({ - ...opts || { }, + const cache = _cache || new NodeCache({ + stdTTL: DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes useClones: false, })