UNPKG

@selldone/sdk-storefront

Version:

A TypeScript SDK to connect to your shop and build a fully functional storefront and website by simply developing a frontend web application. All backend operations are seamlessly managed by the serverless Selldone solution.

39 lines (38 loc) 1.13 kB
/** * A simple implementation of Least Recently Used (LRU) cache. */ export declare class LRUCache<K, V extends ICacheable | null> { private cache; private readonly maxSize; /** * Creates a new instance of LRUCache. * * @param maxSize - The maximum number of items the cache can hold. Defaults to 100. */ constructor(maxSize?: number); /** * Retrieve a value from the cache. * * @param key - The key associated with the value to retrieve. * @returns The value associated with the key, or `undefined` if the key doesn't exist. */ get(key: K): V | undefined; /** * Add a new key-value pair to the cache. If the cache exceeds its `maxSize`, * it will remove the least recently used item. * * @param key - The key of the item to add or update. * @param value - The value of the item to add or update. */ set(key: K, value: V): void; /** * Clears all items from the cache. */ clear(): void; entries(): MapIterator<[K, V]>; length(): number; } interface ICacheable { __date?: Date; } export {};