UNPKG

cache-manager-soumojit-shome

Version:

A lightweight utility for managing cache in web applications using the browser's Cache API.

67 lines (62 loc) 2.59 kB
/** * Adds data to the cache. * @param docId - Unique identifier for the cached data. * @param dataSet - Data to cache. * @param expirationTime - Cache expiration time in milliseconds (default: 30 minutes). * @param cacheName - Name of the cache storage. * @param baseUrl - Base URL used to construct the cache key. * @returns A Promise that resolves to an object indicating the success or failure of the operation. */ export function AddDataIntoCache( docId: string, dataSet: object, expirationTime?: number, cacheName: string, baseUrl: string ): Promise<{ success: boolean; message?: string; error?: string }>; /** * Retrieves data from the cache. * @param docId - Unique identifier for the cached data. * @param cacheName - Name of the cache storage. * @param baseUrl - Base URL used to construct the cache key. * @returns A Promise that resolves to an object containing the cached data if available, or an error message. */ export function GetDataFromCache( docId: string, cacheName: string, baseUrl: string ): Promise<{ success: boolean; data?: object; message?: string; error?: string }>; /** * Updates existing data in the cache. * @param docId - Unique identifier for the cached data. * @param updatedDataSet - New data to merge with the cached data. * @param cacheName - Name of the cache storage. * @param baseUrl - Base URL used to construct the cache key. * @returns A Promise that resolves to an object containing the updated cached data or an error message. */ export function UpdateDataInCache( docId: string, updatedDataSet: object, cacheName: string, baseUrl: string ): Promise<{ success: boolean; data?: object; message?: string; error?: string }>; /** * Deletes specific data from the cache. * @param docId - Unique identifier for the cached data. * @param cacheName - Name of the cache storage. * @param baseUrl - Base URL used to construct the cache key. * @returns A Promise that resolves to an object indicating the success or failure of the deletion. */ export function DeleteDataFromCache( docId: string, cacheName: string, baseUrl: string ): Promise<{ success: boolean; message?: string; error?: string }>; /** * Clears all data from the specified cache. * @param cacheName - Name of the cache storage. * @returns A Promise that resolves to an object indicating the success or failure of the operation. */ export function ClearWholeCacheData( cacheName: string ): Promise<{ success: boolean; message?: string; error?: string }>;