@kwiz/common
Version:
KWIZ common utilities and helpers for M365 platform
23 lines (22 loc) • 1.27 kB
TypeScript
import { ILocalStorageCacheLifetime } from "../types/localstoragecache.types";
export declare const keyPrefix = "kw$_";
export declare const LOCAL_STORAGE_PREFIX = "kwizcom-localstorage-cache";
export declare const LOCAL_STORGAGE_EXPIRATIONS_KEY: string;
export declare const DEFAULT_EXPIRATION: number;
/** When caching logic changes (serialization methods, format, schema), the MODULE_REVISION should be incremented
* and all client side apps will need to be rebuilt */
export declare const MODULE_REVISION = "1";
export declare function isLocalStorageSupported(): boolean;
export declare function getCacheItem<T>(key: string, options?: {
/** Flatted allows serizlising circular dependency objects */
useFlatted?: boolean;
}): T;
export declare function setCacheItem(key: string, value: any, expiration: number | ILocalStorageCacheLifetime | Date, options?: {
/** Flatted allows serizlising circular dependency objects */
useFlatted?: boolean;
}): void;
export declare function removeCacheItem(keyNoPrefix: string): void;
export declare function removeCacheItems(keys: string[]): void;
export declare function getCacheKeys(): string[];
/** cleanup - remove all local storage keys created by this utility */
export declare function clearCache(): void;