khranilka
v1.0.0
Published
Simple, zero-dependency in-memory cache with TTL support for JavaScript
Downloads
9
Maintainers
Readme
Khranilka Simple TTL Cache 🚀
A lightweight, zero-dependency in-memory cache with automatic TTL expiration for Node.js and browser environments. Built with TypeScript for excellent type safety.
Installation
npm install khranilkaFeatures
✅ Simple API - Just 4 methods: get, set, delete, clear
✅ Automatic TTL - Values expire automatically after specified time
✅ Zero Dependencies - No external dependencies, minimal footprint
✅ TypeScript First - Full type definitions included
✅ Universal - Works in Node.js, browsers, and edge runtimes
✅ Memory Safe - Automatic timer cleanup prevents leaks
✅ Fast - O(1) operations using Map
Quick Start
import { Khranilka } from 'khranilka';
const cache = new Khranilka();
// Store a value without TTL (permanent)
cache.set('user:1', { name: 'Alice', age: 30 });
// Store with 5 second TTL
cache.set('token:xyz', 'abc123', { ttl: 5000 });
// Retrieve values
const user = cache.get('user:1'); // { name: 'Alice', age: 30 }
const token = cache.get('token:xyz'); // 'abc123' (if within 5 seconds)
// Delete a value
cache.delete('user:1');
// Clear all values
cache.clear();Documentation
For complete API reference, see API documentation.
