feat: narrower definition of cachestore

This commit is contained in:
Adhiraj Singh
2023-02-21 11:56:27 +05:30
parent 30328eebe1
commit 79aa2e5176
3 changed files with 22 additions and 10 deletions

View File

@@ -2,7 +2,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 type { AuthenticationCreds, CacheStore, SignalDataSet, SignalDataTypeMap, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types'
import { Curve, signedKeyPair } from './crypto'
import { delay, generateRegistrationId } from './generics'
@@ -10,12 +10,12 @@ 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 _cache NodeCache to use
* @param _cache cache store to use
*/
export function makeCacheableSignalKeyStore(
store: SignalKeyStore,
logger: Logger,
_cache?: NodeCache
_cache?: CacheStore
): SignalKeyStore {
const cache = _cache || new NodeCache({
stdTTL: DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes