UNPKG

@sap-cloud-sdk/connectivity

Version:

SAP Cloud SDK for JavaScript connectivity

47 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AsyncCache = void 0; const cache_1 = require("./cache"); /** * @internal * Async wrapper around Cache<T>. */ class AsyncCache { constructor(defaultValidityTime = 0) { this.cache = new cache_1.Cache(defaultValidityTime); } /** * Specifies whether an entry with a given key is defined in cache. * @param key - The entry's key. * @returns A boolean value that indicates whether the entry exists in cache. */ async hasKey(key) { return this.cache.hasKey(key); } /** * Getter of cached entries. * @param key - The key of the entry to retrieve. * @returns The corresponding entry to the provided key if it is still valid, returns `undefined` otherwise. */ async get(key) { return this.cache.get(key); } /** * Setter of entries in cache. * @param key - The entry's key. * @param item - The entry to cache. * @returns A promise to oid. */ async set(key, item) { return this.cache.set(key, item); } /** * Clear all cached items. * @returns A promise to void. */ async clear() { return this.cache.clear(); } } exports.AsyncCache = AsyncCache; //# sourceMappingURL=async-cache.js.map