added first cache

This commit is contained in:
Bojan Kucera 2025-06-05 07:39:54 -04:00
parent eee6135867
commit 3fc123eca3
9 changed files with 210 additions and 9 deletions

26
libs/cache/src/index.ts vendored Normal file
View 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
};