cacheConfig.ts•1.19 kB
// src/cacheConfig.ts
// Define default and specific TTLs for tools in milliseconds
export const toolCacheTTLs: Record<string, number> = {
// Market Data
eod: 12 * 60 * 60 * 1000, // 12 hours
intraday: 15 * 60 * 1000, // 15 minutes (adjust based on interval if needed, but 15min is lowest common denominator for non-pro plans)
splits: 24 * 60 * 60 * 1000, // 24 hours
dividends: 24 * 60 * 60 * 1000, // 24 hours
// Reference Data
tickers: 24 * 60 * 60 * 1000, // 24 hours (for /tickers/[symbol])
tickerslist: 24 * 60 * 60 * 1000, // 24 hours
tickerinfo: 24 * 60 * 60 * 1000, // 24 hours
exchanges: 48 * 60 * 60 * 1000, // 48 hours
currencies: 48 * 60 * 60 * 1000, // 48 hours
timezones: 48 * 60 * 60 * 1000, // 48 hours
// Financial Instruments
index: 6 * 60 * 60 * 1000, // 6 hours (for /indexinfo)
bonds: 12 * 60 * 60 * 1000, // 12 hours (for /bond)
etflist: 24 * 60 * 60 * 1000, // 24 hours
etfholdings: 24 * 60 * 60 * 1000, // 24 hours
// Default TTL for tools not explicitly listed
DEFAULT_TTL: 1 * 60 * 60 * 1000, // 1 hour
};
export const getToolTTL = (toolName: string): number => toolCacheTTLs[toolName] || toolCacheTTLs['DEFAULT_TTL'];