stock-bot/libs/cache/src/index.ts
2025-06-05 07:39:54 -04:00

26 lines
585 B
TypeScript

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
};