1.0.4 • Published 3 years ago

mapped-cache v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Mapped Cache

What is a Mapped Cache?

Simple in-memory cache that maps keys to values.

Usage

import {
    initializeCache, 
    getCache,
    setCache,
    deleteCache
} from "mapped-cache";

// Initialize the cache before use
initializeCache();

// Write to the cache without expire
setCache("key", { value: "value" });
/** key is string, value is any type */


// Write to the cache with expire
// Expire time is in milliseconds
setCache("key", { value: "value" }, 1000 * 60);

// Read from the cache
const value = getCache("key");

// Delete from the cache
deleteCache("key");