From 3be19e694fc7491d45dd7b3c541c91fd9171014e Mon Sep 17 00:00:00 2001 From: Maxim Ciuchitu <35968905+Leichtwind@users.noreply.github.com> Date: Wed, 23 Nov 2022 17:22:08 +0200 Subject: [PATCH] fix(cache): use passed store object --- packages/common/cache/cache.providers.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/common/cache/cache.providers.ts b/packages/common/cache/cache.providers.ts index 082c7029ff5..3d1ca3723a5 100644 --- a/packages/common/cache/cache.providers.ts +++ b/packages/common/cache/cache.providers.ts @@ -3,7 +3,10 @@ import { loadPackage } from '../utils/load-package.util'; import { CACHE_MANAGER } from './cache.constants'; import { MODULE_OPTIONS_TOKEN } from './cache.module-definition'; import { defaultCacheOptions } from './default-options'; -import { CacheManagerOptions } from './interfaces/cache-manager.interface'; +import { + CacheManagerOptions, + CacheStore, +} from './interfaces/cache-manager.interface'; /** * Creates a CacheManager Provider. @@ -28,10 +31,14 @@ export function createCacheManager(): Provider { ...{ ...options, store }, }); } - let cache: string | Function = 'memory'; + let cache: string | Function | CacheStore = 'memory'; defaultCacheOptions.ttl *= 1000; - if (typeof store === 'object' && 'create' in store) { - cache = store.create; + if (typeof store === 'object') { + if ('create' in store) { + cache = store.create; + } else { + cache = store; + } } else if (typeof store === 'function') { cache = store; }