stock-bot/docs/cache-library-usage.md

43 lines
1.6 KiB
Markdown

# 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](./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)
```typescript
// 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
```typescript
// 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
1. **Remove cache type parameters**: Change `createCache('hybrid')` to `createCache()`
2. **Remove name parameter**: The `name` option is no longer needed
3. **Update imports**: Use named imports instead of default import
4. **Use specialized factories**: Consider using `createTradingCache()`, `createMarketDataCache()`, etc.
For complete usage examples and best practices, see [simplified-cache-usage.md](./simplified-cache-usage.md).