Registry / storage / keshi
library3.0.2jsnpmunverified

An in-memory cache for Node and the browser designed for Promises. Current stable version is 3.0.2. Released as a lightweight (under 1KB) alternative to libraries like lru-cache, with built-in support for caching async operations (e.g., fetch) and automatic cleanup of expired items. It accepts human-readable expiry strings via the 'ms' package. Ships TypeScript definitions.

npm install keshi
INSTALL
IMPORT
SIG · KESHI
K
keshi
storagejavascriptv3.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Keshi
import Keshi from 'keshi'
ESM default import is the recommended way in v3.
Keshi
const Keshi = require('keshi')
CommonJS require works in Node.js.
Keshi
import Keshi from 'keshi'
import { Keshi } from 'keshi'
Keshi is exported as default, not a named export.

Shows how to create a Keshi cache, resolve with a Promise and expiry, delete, clear, and teardown.

import Keshi from 'keshi'; const cache = new Keshi(); async function getCachedUser() { return cache.resolve( 'user', () => fetch('https://api.example.com/user').then(r => r.json()), '5mins' ); } const user1 = await getCachedUser(); // Fetches and caches const user2 = await getCachedUser(); // Returns from cache within 5 minutes // Delete specific cache entry cache.delete('user'); // Clear entire cache cache.clear(); // Clean up interval when cache is no longer needed cache.teardown();
Debug
Known issues
breakingIn v3, the import changed from default export to only default export. Previously named exports may have existed.
fix
Ensure you use import Keshi from 'keshi' or const Keshi = require('keshi'). Do not destructure.
affects: >=3.0.0
deprecatedThe method name 'del' was deprecated in v2.0.0 and removed in v3.0.0. Use 'delete' instead.
fix
Replace cache.del(key) with cache.delete(key).
affects: >=2.0.0 <3.0.0
gotchacache.resolve always returns a Promise, even for plain values. Must always be awaited.
fix
Always use await cache.resolve(...) or .then().
affects: >=1.0.0
gotchaCache keys are not safely escaped. If using dynamic keys, ensure they don't contain characters that could cause unintended collisions, especially when using matchStart deletion.
fix
Consider prefixing keys with a namespace and validating key strings.
affects: >=1.0.0
Errors
Common errors & fixes
Keshi is not a constructor
Using a named import instead of default import.
fix
Use import Keshi from 'keshi' instead of import { Keshi } from 'keshi'.
cache.resolve(...) returns undefined
Forgetting to return a value from the getValue function.
fix
Ensure getValue returns a value or Promise.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies
msrequiredUsed to parse human-readable expiry strings like '5mins'
Agent activity
14 hits · last 30 days
node
14
Resources
packagekeshi
keshi — npm install keshi · libregistry