ketting
Version:
Opinionated HATEOAS / Rest client.
36 lines (35 loc) • 1.12 kB
TypeScript
import { State } from '../state/index.js';
import { ForeverCache } from './forever.js';
/**
* ShortCache stores items in the cache for a short time.
*
* This cache can be a good choice if your server heavily relies
* on HTTP cache headers and Ketting runs in your browser, or if in general
* you want very up-to-date data.
*
* The reason in this scenarios it's useful to still have a 'very temporary'
* cache, is because during many operations `get()` may be called in rapid
* succession, and it also allows for enough time for 'embedded items' to
* pe placed in the cache and extracted again.
*/
export declare class ShortCache extends ForeverCache {
private cacheTimeout;
private activeTimers;
/**
* Create the short cache.
*
* cacheTimeout is specified in ms.
*/
constructor(cacheTimeout?: number);
/**
* Store a State object.
*
* This function will clone the state object before storing
*/
store(state: State): void;
private setTimer;
/**
* Clean up any dangling references to avoid memory leaks.
*/
destroy(): void;
}