Skip to content

Vish_cache, a Caching package inspired from Caffeine caching library for JVM supported apps.

Notifications You must be signed in to change notification settings

vishwesh5544/vish_cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vish-cache

vish-cache is an advanced caching system for Node.js, inspired by Caffeine from the Java world. It provides highly configurable, efficient, and extensible caching strategies with features like TTL, eviction policies (LRU, LFU), asynchronous cache loading, and more.

Features

  • Time-to-Live (TTL) expiration: Set custom TTLs for cache entries.
  • Eviction Policies: Supports multiple eviction strategies like Least Recently Used (LRU) and Least Frequently Used (LFU).
  • Async Cache Loading: Automatically fetch missing cache entries from a loader (e.g., database or API).
  • Metrics and Statistics: Track cache hit/miss rates, evictions, and other performance metrics.
  • Highly Configurable: Easily plug in custom eviction and expiration policies.
  • Bulk Operations: Set and get multiple cache entries at once.

Installation

npm install vish-cache

Or with Yarn:

yarn add vish-cache

Basic Usage

import { Cache } from 'vish-cache';

const cache = new Cache<string>({
    ttl: 60000,  // 1 minute default expiration
    maxSize: 100,  // Max 100 entries before eviction
    evictionPolicy: 'LRU'  // Least Recently Used strategy
});

// Add an entry
cache.set('key', 'value');

// Get an entry
const value = cache.get('key');

// Remove an entry
cache.delete('key');

// Bulk operations
cache.setMany([{ key: 'key1', value: 'value1' }, { key: 'key2', value: 'value2' }]);
const results = cache.getMany(['key1', 'key2']);

Configuration

The cache can be configured with various options:

  • ttl: Time-to-live for cache entries.
  • maxSize: Maximum number of entries before eviction.
  • evictionPolicy: Strategy for evicting cache entries (e.g., LRU, LFU).
  • loader: Asynchronous loader for fetching missing cache entries.
  • enableStatistics: Enables cache hit/miss tracking and other metrics.

Neovim Configuration

For those interested in my Neovim setup, feel free to check out my configuration repository:
Neovish Config

Contact

If you have any questions or suggestions, feel free to reach out:
[email protected]

About

Vish_cache, a Caching package inspired from Caffeine caching library for JVM supported apps.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published