@dbs-portal/core-api
Version:
HTTP client and API utilities for DBS Portal
91 lines • 2.04 kB
TypeScript
/**
* Browser storage cache implementation
*/
import type { CacheEntry } from '../types';
import type { CacheStorage } from './cache-manager';
/**
* Browser storage cache implementation (localStorage/sessionStorage)
*/
export declare class StorageCache implements CacheStorage {
private storage;
private prefix;
constructor(storageType?: 'localStorage' | 'sessionStorage');
/**
* Gets a cache entry
*/
get<T>(key: string): CacheEntry<T> | null;
/**
* Sets a cache entry
*/
set<T>(key: string, entry: CacheEntry<T>): void;
/**
* Deletes a cache entry
*/
delete(key: string): void;
/**
* Clears all cache entries
*/
clear(): void;
/**
* Gets the number of cached entries
*/
size(): number;
/**
* Gets all cache keys
*/
keys(): string[];
/**
* Gets all cache entries
*/
entries(): Array<[string, CacheEntry]>;
/**
* Checks if a key exists in cache
*/
has(key: string): boolean;
/**
* Gets storage usage information
*/
getStorageInfo(): {
used: number;
available: number;
total: number;
};
/**
* Cleans up expired entries
*/
cleanup(): number;
/**
* Evicts oldest entries
*/
evictOldest(count: number): string[];
/**
* Checks if error is quota exceeded
*/
private isQuotaExceededError;
/**
* Gets cache statistics
*/
getStats(): {
size: number;
storageUsed: number;
storageAvailable: number;
hitRate: number;
};
/**
* Exports cache data
*/
export(): Record<string, CacheEntry>;
/**
* Imports cache data
*/
import(data: Record<string, CacheEntry>): void;
/**
* Checks if storage is available
*/
isAvailable(): boolean;
/**
* Gets storage type
*/
getStorageType(): 'localStorage' | 'sessionStorage' | 'unavailable';
}
//# sourceMappingURL=storage-cache.d.ts.map