UNPKG

mya-cli

Version:

MYA - AI-Powered Stock & Options Analysis CLI Tool

91 lines (90 loc) 2.33 kB
/** * Cache storage implementation for API responses */ /** * Interface for cache storage */ export interface CacheStorage { get<T>(key: string): Promise<T | null>; set<T>(key: string, value: T, ttl?: number): Promise<void>; delete(key: string): Promise<void>; clear(): Promise<void>; } /** * Interface for KVNamespace */ interface KVNamespace { get(key: string, options?: { type?: 'text' | 'json' | 'arrayBuffer' | 'stream'; }): Promise<string | object | ArrayBuffer | ReadableStream | null>; put(key: string, value: string | object | ArrayBuffer | ReadableStream, options?: { expirationTtl?: number; }): Promise<void>; delete(key: string): Promise<void>; list(options?: { prefix?: string; limit?: number; }): Promise<{ keys: string[]; list_complete: boolean; }>; } /** * Implementation of cache storage using Cloudflare KV */ export declare class CloudflareKVCache implements CacheStorage { private namespace; private defaultTTL; constructor(namespace: KVNamespace, defaultTTL?: number); /** * Get a value from cache */ get<T>(key: string): Promise<T | null>; /** * Set a value in cache */ set<T>(key: string, value: T, ttl?: number): Promise<void>; /** * Delete a value from cache */ delete(key: string): Promise<void>; /** * Clear all values from cache */ clear(): Promise<void>; } /** * Implementation of cache storage using memory * Used for testing and development */ export declare class MemoryCache implements CacheStorage { private cache; private defaultTTL; constructor(defaultTTL?: number); /** * Get a value from cache */ get<T>(key: string): Promise<T | null>; /** * Set a value in cache */ set<T>(key: string, value: T, ttl?: number): Promise<void>; /** * Delete a value from cache */ delete(key: string): Promise<void>; /** * Clear all values from cache */ clear(): Promise<void>; } /** * Factory for creating cache storage instances */ export declare class CacheStorageFactory { /** * Create a cache storage instance */ static createStorage(namespace?: KVNamespace, defaultTTL?: number): CacheStorage; } export {};