@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
37 lines (36 loc) • 1.41 kB
TypeScript
/**
* @module Cache
*/
import { type ICacheAdapter } from "../../../../cache/contracts/_module-exports.js";
import type { TimeSpan } from "../../../../utilities/_module-exports.js";
/**
* To utilize the `MemoryCacheAdapter`, you must create instance of it.
*
* IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
* @group Adapters
*/
export declare class MemoryCacheAdapter<TType> implements ICacheAdapter<TType> {
private readonly map;
private readonly timeoutMap;
/**
* You can provide an optional {@link Map | `Map`}, that will be used for storing the data.
* @example
* ```ts
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/adapters";
*
* const map = new Map<any, any>();
* const cacheAdapter = new MemoryCacheAdapter(map);
* ```
*/
constructor(map?: Map<string, unknown>);
get(key: string): Promise<TType | null>;
getAndRemove(key: string): Promise<TType | null>;
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
put(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
update(key: string, value: TType): Promise<boolean>;
increment(key: string, value: number): Promise<boolean>;
remove(key: string): Promise<boolean>;
removeMany(keys: string[]): Promise<boolean>;
removeAll(): Promise<void>;
removeByKeyPrefix(prefix: string): Promise<void>;
}