
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
cache-manager-fs-hash
Advanced tools
Package to cache key-value pairs in JSON files.
npm install cache-manager-fs-hash
JSON.stringify
-able to diskHere is an example that demonstrates how to use the filesystem cache store.
const { DiskStore } = require('cache-manager-fs-hash');
const diskStore = new DiskStore({
path: 'diskcache', // path for cached files (default: cache)
ttl: 60 * 60 * 1000, // time to live in milliseconds
// (default: never expires)
zip: true, // zip files to save disk space (default: false)
hash: false, // keys are hashed to generate filenames (default: true)
// set to false to use plain keys as filenames
});
(async () => {
await diskStore.set('key', 'value');
console.log(await diskStore.get('key')); // "value"
await diskStore.del('key');
console.log(await diskStore.get('key')); // undefined
await diskStore.set('key', 'value', 1000); // with custom TTL
console.log(await diskStore.ttl('key')); // 999 milliseconds
// delete stored files
await diskStore.reset();
})();
Here is an example that demonstrates how to use the store with the node-cache-manager module.
const cacheManager = require('cache-manager');
const { DiskStore } = require('cache-manager-fs-hash');
const diskCache = cacheManager.createCache(new DiskStore({
path: 'diskcache', // path for cached files
// ... other options
}));
(async () => {
await diskCache.set('key', 'value');
console.log(await diskCache.get('key')); // "value"
console.log(await getUserCached(5)); // {id: 5, name: '...'}
console.log(await getUserCached(5)); // {id: 5, name: '...'}
function getUserCached(userId) {
return diskCache.wrap(userId, function () {
return getUser(userId);
});
}
async function getUser(userId) {
await new Promise(r => setTimeout(r, 100)); // sleep 0.1 seconds
return {id: userId, name: '...' + Math.random()};
}
})();
The library saves each cached item as a separate file under the specified directory. Writes use a .lock
file to ensure that multiple instances accessing the same cache file do not interfere with each other.
npm test
cache-manager-fs-hash is licensed under the MIT license.
[3.0.0] - 2025-08-30
hash
option. Can be set to false to use the plain key as filename instead of the hashed keyMap
, Set
, BigInt
, Error
, ArrayBuffer
and TypedArrays (e.g. Int8Array
, ...)FAQs
file system store for node cache manager
The npm package cache-manager-fs-hash receives a total of 56,164 weekly downloads. As such, cache-manager-fs-hash popularity was classified as popular.
We found that cache-manager-fs-hash demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.