@empathyco/x-storage-service
Version:
Storage service with TTL
45 lines (44 loc) • 1.02 kB
TypeScript
import { StorageService } from './storage-service';
/**
* In memory implementation of the storage service.
*
* @public
*/
export declare class InMemoryStorageService implements StorageService {
protected storage: Record<string, any>;
/**
* Adds a new item in the storage.
*
* @param key - The key of the item.
* @param item - The item to save.
*
* @public
*/
setItem(key: string, item: any): void;
/**
* Retrieves an item by its key.
*
* @param key - The key of the item.
* @returns The founded item or null.
*
* @public
*/
getItem<Item = any>(key: string): Item | null;
/**
* Removes an item by its key.
*
* @param key - The key of the item.
* @returns The removed item or null.
*
* @public
*/
removeItem<Item = any>(key: string): Item | null;
/**
* Clears the storage..
*
* @returns The number of removed items.
*
* @public
*/
clear(): number;
}