LiquidCache is an easy-to-setup, map-based caching system for Node.js, written in TypeScript. It allows you to store key-value pairs in memory and configure cache expiration intervals for optimized data retrieval.
- In-memory storage of key-value pairs for fast access.
- Configurable cache expiration intervals to ensure data freshness.
- Type-safe operations due to TypeScript integration.
- Straightforward API for managing cache data.
Install LiquidCache using npm:
npm install liquidcache
Make sure to compile the TypeScript to JavaScript before using LiquidCache:
npm run build
Here's how you can use LiquidCache in your TypeScript code:
import { LiquidCache } from 'liquidcache';
// Create a new cache instance
const cache = new LiquidCache<string>();
// Set a value in the cache
cache.set('name', 'FlaringPhoenix');
// Retrieve a value from the cache
const value = cache.get('name'); // 'FlaringPhoenix'
// Remove a value from the cache
cache.delete('name');
// Set a value in the cache with an expiration time (in milliseconds)
cache.set('name', 'FlaringPhoenix', 5000);
// After 5 seconds, 'name' will be automatically removed from the cache
JSDoc is automatically generated with each release, see more here.
If you need help with configuring or using LiquidCache, please open an issue here.
Contributions are welcome! For significant changes, please open an issue first to discuss what you would like to change. Don't forget to update tests as necessary.
This project is licensed under the MIT License - see the LICENSE file for details.