@croct/cache
Version:
An abstraction layer for caching.
22 lines (21 loc) • 613 B
TypeScript
import { Instant } from '@croct/time';
import { JsonCompatible, JsonValue } from '@croct/json';
/**
* A cache entry associated with a timestamp.
*/
export type TimestampedCacheEntry<T> = Readonly<{
/**
* The cached value.
*/
value: T;
/**
* The cache timestamp.
*
* Semantics and usage are implementation-specific.
*/
timestamp: Instant;
}>;
export declare namespace TimestampedCacheEntry {
function toJSON<T extends JsonCompatible>(entry: TimestampedCacheEntry<T>): string;
function fromJSON<T extends JsonValue>(json: string): TimestampedCacheEntry<T>;
}