UNPKG

@zenfs/core

Version:

A filesystem, anywhere

37 lines (36 loc) 697 B
/* Experimental caching */ /** * Whether the cache is enabled */ export let isEnabled = false; /** * Sets whether the cache is enabled or not */ export function setEnabled(value) { isEnabled = value; } const stats = new Map(); /** * Gets stats from the cache, if they exist and the cache is enabled. */ export function getStats(path) { if (!isEnabled) return; return stats.get(path); } /** * Adds stats if the cache is enabled */ export function setStats(path, value) { if (!isEnabled) return; stats.set(path, value); } /** * Clears the cache if it is enabled */ export function clearStats() { if (!isEnabled) return; stats.clear(); }