@sonatel-os/juf
Version:
The community SDK for Orange Money, SMS, Email & Sonatel APIs on the Orange Developer Platform.
42 lines (39 loc) • 1.35 kB
TypeScript
/**
* Singleton instance of Cache with the standard auth token TTL.
* @type {Cache}
*/
declare const CachingSystem: Cache;
/**
* @class Cache
* @classdesc Handles caching of data with expiration using NodeCache.
* Provides methods to store and retrieve cached data, with error handling for reliable cache management.
*
* @example
* const myCache = new Cache(300);
* myCache.store('myKey', { data: 'value' });
* const cachedData = myCache.retrieve('myKey');
*/
declare class Cache {
/**
* Creates an instance of Cache.
* @param {number} ttlSeconds - Time-to-live (TTL) in seconds for cached items.
*/
constructor(ttlSeconds: number);
/**
* Stores a value in the cache with a specified key.
*
* @param {string} key - The key under which the value is stored.
* @param {*} value - The value to be stored. Must be serializable to JSON.
* @returns {boolean} Returns true if stored successfully, otherwise false.
*/
store(key: string, value: any): boolean;
/**
* Retrieves a value from the cache by its key.
*
* @param {string} key - The key to retrieve the value.
* @returns {object|null} Returns the parsed cached value if found, otherwise null.
*/
retrieve(key: string): object | null;
#private;
}
export { Cache as C, CachingSystem as a };