| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A lightweight, high-performance in-memory cache for Node.js applications with TypeScript support.
npm install fast-memory-cache
# or
yarn add fast-memory-cache
# or
pnpm add fast-memory-cacheimport MemoryCache from 'fast-memory-cache';
interface User {
id: number;
name: string;
}
const cache = new MemoryCache();
// Type-safe storage and retrieval
cache.set<User>('user', { id: 1, name: 'John' });
const user = cache.get<User>('user'); // User type
// With expiration
cache.set<string>('token', 'abc123', 300); // expires in 5 minutesconst MemoryCache = require('fast-memory-cache');
// Create a new cache instance
const cache = new MemoryCache();
// Store a value
cache.set('user', { id: 1, name: 'John' });
// Retrieve a value
const user = cache.get('user'); // { id: 1, name: 'John' }
// Store with expiration (in seconds)
cache.set('session', 'abc123', 60); // expires in 60 seconds
// Delete a value
cache.delete('user');
// Clear all cache
cache.clear();const cache = new MemoryCache();Retrieves a value from the cache.
Stores a value in the cache.
Removes a value from the cache.
Removes all values from the cache.
Fast Memory Cache is designed to be extremely lightweight and performant:
Fast Memory Cache is ideal for:
MIT
If you find this package useful, consider:
| Back | FazBrowse Home | New Git URL |