typerinth
Version:
A TypeScript library for interacting with the Modrinth API.
48 lines (47 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class CacheManager {
cache;
constructor(cache) {
if (cache)
this.cache = cache;
else
this.cache = null;
}
/**
* Checks if the cache is enabled
* @returns {boolean} Whether the cache is enabled
*/
isEnabled() {
return this.cache !== null;
}
/**
* Gets a value from the cache
* @param key - The key to get
*/
get(key) {
if (!this.cache)
return null;
return this.cache.get(key);
}
/**
* Sets a value in the cache
* @param key - The key to set
* @param value - The value to set
*/
set(key, value) {
if (!this.cache)
return;
this.cache.set(key, value);
}
/**
* Deletes a value from the cache
* @param key - The key to delete
*/
delete(key) {
if (!this.cache)
return;
this.cache.del(key);
}
}
exports.default = CacheManager;