crewai-ts
Version:
TypeScript port of crewAI for agent-based workflows
133 lines • 3.12 kB
TypeScript
/**
* RedisStorageAdapter
*
* A Redis-based implementation of the StorageAdapter interface
* Optimized for distributed systems with high throughput requirements
*/
import { BaseStorageAdapter, StorageAdapterOptions } from './StorageAdapter.js';
/**
* RedisStorageAdapter Options
*/
export interface RedisStorageOptions extends StorageAdapterOptions {
/**
* Redis connection URL (redis://user:password@host:port/db)
*/
url?: string;
/**
* Redis host
*/
host?: string;
/**
* Redis port
*/
port?: number;
/**
* Redis password
*/
password?: string;
/**
* Redis database index
*/
db?: number;
/**
* Cluster nodes configuration for Redis cluster mode
* Array of {host, port} objects
*/
clusterNodes?: Array<{
host: string;
port: number;
}>;
/**
* Key prefix for all Redis keys
*/
keyPrefix?: string;
/**
* Connection timeout in milliseconds
*/
connectTimeout?: number;
/**
* Operation timeout in milliseconds
*/
commandTimeout?: number;
/**
* Enable client-side caching
*/
enableCache?: boolean;
/**
* Maximum cache size
*/
maxCacheSize?: number;
/**
* Whether to use Redis cluster mode
*/
useCluster?: boolean;
/**
* Default key expiration time in seconds (TTL)
*/
defaultExpireSeconds?: number;
}
/**
* RedisStorageAdapter implements the StorageAdapter interface
* using Redis for high-performance distributed storage
*
* Note: This implementation requires the 'redis' package
* npm install redis
*/
export declare class RedisStorageAdapter extends BaseStorageAdapter {
private client;
private connected;
private connecting;
private connectionPromise;
private enableCache;
private maxCacheSize;
private cache;
private keyPrefix;
private defaultExpireSeconds;
private useCluster;
constructor(options: RedisStorageOptions);
/**
* Initialize Redis client with optimal configuration
*/
private initClient;
/**
* Ensure Redis client is connected
*/
private ensureConnected;
/**
* Get the full Redis key with namespace and key prefix
*/
private getRedisKey;
/**
* Add an item to the cache with LRU eviction
*/
private addToCache;
/**
* Save a value to Redis with optional expiration
*/
save(key: string, value: any): Promise<void>;
/**
* Load a value from Redis with caching
*/
load(key: string): Promise<any | null>;
/**
* Delete a value from Redis with cache invalidation
*/
delete(key: string): Promise<boolean>;
/**
* Clear all values in the namespace
*/
clear(): Promise<void>;
/**
* Get all keys in the namespace
*/
keys(): Promise<string[]>;
/**
* Close the Redis client connection
*/
close(): Promise<void>;
/**
* Get Redis stats
*/
getStats(): Promise<any>;
}
//# sourceMappingURL=RedisStorageAdapter.d.ts.map