1.6 KiB
1.6 KiB
Cache Library Usage Guide
⚠️ DEPRECATED: This documentation is outdated. The cache library has been simplified to only use Redis/Dragonfly.
Please see simplified-cache-usage.md for current usage instructions.
The @stock-bot/cache library now provides a simplified Redis-only caching solution designed specifically for trading bot applications.
Migration from Old API
If you're migrating from the old cache API, here are the key changes:
Old API (DEPRECATED)
// These are no longer supported
const cache = createCache('auto');
const cache = createCache('memory');
const cache = createCache('hybrid');
const cache = createCache('redis');
// Direct imports no longer available
import { MemoryCache, HybridCache } from '@stock-bot/cache';
New Simplified API
// Use factory functions with options only
const cache = createCache({ keyPrefix: 'app:', ttl: 3600 });
const tradingCache = createTradingCache();
const marketCache = createMarketDataCache();
// Only Redis cache is available
import { RedisCache, RedisConnectionManager } from '@stock-bot/cache';
Quick Migration Steps
- Remove cache type parameters: Change
createCache('hybrid')tocreateCache() - Remove name parameter: The
nameoption is no longer needed - Update imports: Use named imports instead of default import
- Use specialized factories: Consider using
createTradingCache(),createMarketDataCache(), etc.
For complete usage examples and best practices, see simplified-cache-usage.md.