added first cache
This commit is contained in:
parent
eee6135867
commit
3fc123eca3
9 changed files with 210 additions and 9 deletions
26
libs/cache/src/index.ts
vendored
Normal file
26
libs/cache/src/index.ts
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { RedisCache } from './providers/redis-cache';
|
||||
import { MemoryCache } from './providers/memory-cache';
|
||||
import type { CacheProvider, CacheOptions } from './types';
|
||||
|
||||
/**
|
||||
* Factory for creating cache providers.
|
||||
*
|
||||
* @param type 'redis' | 'memory'
|
||||
* @param options configuration for the cache
|
||||
*/
|
||||
export function createCache(
|
||||
type: 'redis' | 'memory',
|
||||
options: CacheOptions = {}
|
||||
): CacheProvider {
|
||||
if (type === 'redis') {
|
||||
return new RedisCache(options);
|
||||
}
|
||||
return new MemoryCache(options);
|
||||
}
|
||||
|
||||
export {
|
||||
CacheProvider,
|
||||
CacheOptions,
|
||||
RedisCache,
|
||||
MemoryCache
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue