Skip to content

Commit

Permalink
fix(cache): use passed store object
Browse files Browse the repository at this point in the history
  • Loading branch information
mciuchitu committed Nov 23, 2022
1 parent 220b098 commit 3be19e6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/common/cache/cache.providers.ts
Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down

0 comments on commit 3be19e6

Please sign in to comment.