hp-app-bundle-sdk
Version:
A comprehensive SDK for building mini-applications.
79 lines • 2.5 kB
TypeScript
/**
* Cache item interface
*/
export interface CacheItem<T = any> {
/** Cached value */
value: T;
/** Timestamp when the item was cached */
timestamp: number;
/** Time-to-live in milliseconds (optional) */
ttl?: number;
}
/**
* Cache module interface
*/
export interface ICacheModule {
/**
* Store data in cache
* @param key Cache key
* @param value Value to cache
* @param isLRUCache Whether to use LRU cache (default: true)
* @param ttl Time-to-live in milliseconds (optional)
*/
putCache<T = any>(key: string, value: T, isLRUCache?: boolean, ttl?: number): Promise<void>;
/**
* Retrieve data from cache
* @param key Cache key
* @param isLRUCache Whether to use LRU cache (default: true)
* @param isAnonymousUser Whether to access anonymous user cache (default: false)
*/
getCache<T = any>(key: string, isLRUCache?: boolean, isAnonymousUser?: boolean): Promise<T | null>;
/**
* Remove specific cache item
* @param key Cache key
* @param isLRUCache Whether to use LRU cache (default: true)
* @param isAnonymousUser Whether to access anonymous user cache (default: false)
*/
clearCache(key: string, isLRUCache?: boolean, isAnonymousUser?: boolean): Promise<void>;
/**
* Clear all cache items
* @param isLRUCache Whether to clear LRU cache (default: true)
*/
clearAllCache(isLRUCache?: boolean): Promise<void>;
/**
* Store JSON data in cache
* @param key Cache key
* @param value Value to cache (will be stringified)
* @param isLRUCache Whether to use LRU cache (default: true)
*/
putJson<T = any>(key: string, value: T, isLRUCache?: boolean): Promise<void>;
/**
* Retrieve JSON data from cache
* @param key Cache key
* @param isLRUCache Whether to use LRU cache (default: true)
* @param isAnonymousUser Whether to access anonymous user cache (default: false)
*/
getJson<T = any>(key: string, isLRUCache?: boolean, isAnonymousUser?: boolean): Promise<T | null>;
}
/**
* Cache operation result
*/
export interface CacheOperationResult {
success: boolean;
error?: {
code: string;
message: string;
};
affectedKeys?: string[];
}
/**
* Cache statistics
*/
export interface CacheStats {
totalItems: number;
lruCacheSize: number;
persistentCacheSize: number;
memoryUsage: number;
hitRate: number;
}
//# sourceMappingURL=types.d.ts.map