@jahed/sparql-engine
Version:
SPARQL query engine for servers and web browsers.
42 lines (41 loc) • 1.55 kB
TypeScript
import { LRUCache } from "lru-cache";
import type { AsyncCache, AsyncCacheEntry, Cache } from "./types.ts";
/**
* An in-memory LRU cache
*/
export declare class BaseLRUCache<K extends {}, T extends {}> implements Cache<K, T> {
private readonly _content;
/**
* Constructor
* @param maxSize - The maximum size of the cache
* @param maxAge - Maximum age in ms
* @param length - Function that is used to calculate the length of stored items
* @param onDispose - Function that is called on items when they are dropped from the cache
*/
constructor(options: LRUCache.Options<K, T, unknown>);
put(key: K, item: T): void;
has(key: K): boolean;
get(key: K): T | null;
delete(key: K): void;
count(): number;
}
/**
* A base class for implementing an asynchronous cache.
* It simply needs to provides a data structure used to cache items
*/
export declare abstract class BaseAsyncCache<K extends {}, T extends {}, I> implements AsyncCache<K, T, I> {
private readonly _cache;
constructor(cache: Cache<K, AsyncCacheEntry<T, I>>);
has(key: K): boolean;
update(key: K, item: T, writerID: I): void;
commit(key: K, writerID: I): void;
get(key: K): Promise<T[]> | null;
delete(key: K, writerID: I): void;
count(): number;
}
/**
* An in-memory LRU implementation of an asynchronous cache.
*/
export declare class AsyncLRUCache<K extends {}, T extends {}, I> extends BaseAsyncCache<K, T, I> {
constructor(options: LRUCache.Options<K, AsyncCacheEntry<T, I>, unknown>);
}