@sap-cloud-sdk/core
Version:
SAP Cloud SDK for JavaScript core
74 lines • 2.33 kB
TypeScript
import moment from 'moment';
interface CacheInterface<T> {
hasKey(key: string): boolean;
get(key: string): T | undefined;
set(key: string, item: T, expirationTime?: number): void;
}
/**
* @hidden
*/
export interface CacheEntry<T> {
expires?: moment.Moment;
entry: T;
}
/**
* Enumerator that selects the isolation type of destination in cache.
*/
export declare enum IsolationStrategy {
Tenant = "Tenant",
User = "User",
Tenant_User = "TenantUser",
No_Isolation = "NoIsolation"
}
export interface CachingOptions {
/**
* A boolean value that indicates whether to read destinations from cache.
*/
useCache?: boolean;
/**
* The isolation strategy used for caching destinations. For the available options, see [[IsolationStrategy]].
* By default, IsolationStrategy.Tenant is set.
*/
isolationStrategy?: IsolationStrategy;
}
/**
* Representation of a cache to transiently store objects locally for faster access.
* @typeparam T - Type of the cache entries.
*/
export declare class Cache<T> implements CacheInterface<T> {
/**
* Object that stores all cached entries.
*/
private cache;
/**
* Default validity period for each entry in cache.
* If `undefined`, all cached entries will be valid indefinitely.
*/
private defaultValidityTime;
constructor(validityTime?: moment.MomentInputObject);
/**
* Clear all cached items.
*/
clear(): void;
/**
* Specifies whether an entry with a given key is defined in cache.
* @param key - The entry's key
* @returns boolean A boolean value that indicates whether the entry exists in cache
*/
hasKey(key: string): boolean;
/**
* 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.
*/
get(key: string | undefined): T | undefined;
/**
* Setter of entries in cache.
* @param key - The entry's key
* @param entry - The entry to cache
* @param expirationTime - The time expressed in UTC in which the given entry expires
*/
set(key: string | undefined, entry: T, expirationTime?: number): void;
}
export {};
//# sourceMappingURL=cache.d.ts.map