/
oinktech
/
radar-map
Обзор
Документация
Войти
/
oinktech
/
radar-map
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
master
services/cache.js
29 строк
526 B
TwixoffStudio
Create: server.js, app.js, index.html, styles.css, russia.js, sources.js, ukraine.js, cache.js, russia.js, ukraine.js, .gitignore, LICENSE, package.json, README.md
09 авг 2026, 01:04
Верифицирован
09 авг 2026, 01:04
d92e294
Код
Авторство
О чём код?
/** * Простой in-memory кэш с TTL */ class Cache { constructor() { this.store = new Map(); } set(key, value, ttlSeconds = 60) { const expires = Date.now() + ttlSeconds * 1000; this.store.set(key, { value, expires }); } get(key) { const item = this.store.get(key); if (!item) return null; if (Date.now() > item.expires) { this.store.delete(key); return null; } return item.value; } clear() { this.store.clear(); } } module.exports = new Cache();