npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mini-cache-ttl

v1.4.3

Published

*Простой, легковесный in-memory кэш с TTL (Time-To-Live) для Node.js и браузера.* Поддерживает локальные хранилища, централизованный сервер и интеграцию с express-session.

Readme

mini-cache-ttl

Простой, легковесный in-memory кэш с TTL (Time-To-Live) для Node.js и браузера. Поддерживает локальные хранилища, централизованный сервер и интеграцию с express-session.

Особенности

  • Автоматическое удаление устаревших записей по TTL
  • Несколько изолированных хранилищ через createStore()
  • Готовый HTTP-сервер для централизованного кэша
  • Клиент для работы с удалённым кэшем (createRemoteStore)
  • Адаптер для express-session
  • Нет внешних зависимостей (кроме Express для сервера)

Установка

npm install mini-cache-ttl

Быстрый старт

Локальное использование

import cache from 'mini-cache-ttl';

cache.set('user:123', { name: 'Alice' }, 60); // TTL = 60 сек
console.log(cache.get('user:123')); // { name: 'Alice' }

Изолированное хранилище

import { createStore } from 'mini-cache-ttl';

const sessionCache = createStore();
sessionCache.set('sid', 'abc123', 1800);

Express Session Store

import session from 'express-session';
import { expressSessionStore } from 'mini-cache-ttl';

const MiniCacheStore = await expressSessionStore();

app.use(session({
  store: new MiniCacheStore({ ttl: 3600 }),
  secret: 'my-secret',
  resave: false,
  saveUninitialized: false
}));

Удалённый кэш (клиент)

import { createRemoteStore } from 'mini-cache-ttl/client';

//token is not a required parameter 
const sharedCache = createRemoteStore('http://localhost:4000', 'my-store','your_token');
await sharedCache.set('counter', 1, 60);
console.log(await sharedCache.get('counter')); // 1

Запуск сервера

После установки:

# Варианты запуска
# Базовый запускы
npx mini-cache-ttl-server

# На порту 4000
npx mini-cache-ttl-server --port 4000

# С токеном
npx mini-cache-ttl-server -p 4000 -t my-secret-key

Или программно:

import { createServer } from 'mini-cache-ttl/server';

//token is not a required parameter 
createServer({ port: 4000 ,token:'your_token'});

Подключить монитор ресурсов

программно

import { createApp } from 'mini-cache-ttl/server';
import { monitor } from 'mini-cache-ttl/monitor';

const { app, stores } = createApp();

// Подключаем мониторинг
monitor(app, { stores });

app.listen(4000, () => {
  console.log('✅ Кэш-сервер с мониторингом запущен на http://localhost:4000');
});

CLI

npx mini-cache-ttl-server -p 4000 --monitor
# или
npx mini-cache-ttl-server -p 4000 -m

Просмотреть монитор

Эндпоинты для просмотра статистики и состояния

/stats /helth

Полный API

Все методы доступны как в локальном, так и в удалённом режиме:

| Метод | Описание | |--------|----------| |get(key)|Получить значение| |set(key, value, ttlSec?)|Установить значение с TTL| |update(key, value, ttlSec?)|Обновить, если ключ существует| |del(key)|Удалить ключ| |rename(oldKey, newKey)|Переименовать ключ| |keys()|Получить все действующие ключи| |size()|Количество ключей| |clear()|Очистить всё хранилище| |touch(key, ttlSec)|Продлить TTL| |has(key)|Проверить существование|

Демонстрация

Полный пример использования с двумя микросервисами и общим кэшем:

https://github.com/O9nix/mini-cache-ttl-demo

В демонстрации показано:

  • Работа локального и общего кэша
  • Веб-интерфейс для управления
  • Совместное использование данных между сервисами