criado cache m

This commit is contained in:
Luiz Silva 2025-07-17 10:21:43 -03:00
parent 326112a16a
commit 3c7926df4d
7 changed files with 122 additions and 1 deletions

View file

@ -0,0 +1,23 @@
const _cache = {};
const cacheM = (chave, valor, validadeSeg) => {
const txChave = typeof chave == "string" ? chave : typeof chave == "number" ? String(chave) : encodeURIComponent(JSON.stringify(chave));
const validade = validadeSeg && (/* @__PURE__ */ new Date()).getTime() + validadeSeg * 1e3;
if (valor !== void 0) {
_cache[txChave] = {
valor,
validade
};
}
const busca = _cache[txChave];
if (busca?.validade && busca.validade < (/* @__PURE__ */ new Date()).getTime()) {
return void 0;
}
return busca?.valor;
};
const verCacheM = () => _cache;
const cacheMemoria = cacheM;
export {
cacheM,
cacheMemoria,
verCacheM
};