{"library":"node-file-cache","title":"Simple File-Based Cache","description":"node-file-cache is a straightforward, file-based caching module for Node.js, currently at version 1.0.2. It leverages `lowdb` for persistent storage, allowing developers to store key-value pairs with optional lifespans and tags for granular expiry. Its design emphasizes simplicity over advanced features or high-throughput performance. Given its age and the explicit mention of Node.js 4.4.5 as a minimum requirement (a version from 2016), it appears to be an unmaintained package with an irregular or non-existent release cadence. It's best suited for small-scale applications where a simple, durable, local cache is sufficient and high concurrency or complex cache invalidation strategies are not required.","language":"javascript","status":"abandoned","last_verified":"Sat Apr 25","install":{"commands":["npm install node-file-cache"],"cli":null},"imports":["const cache = require('node-file-cache').create();","const cache = require('node-file-cache').create({ file: 'my-cache.json', life: 7200 });","const cache = require('node-file-cache').create();\ncache.set('key', 'value');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const cache = require('node-file-cache').create(); // default configuration\n\nconst key = 'my-cache-key';\nconst item = {\n    name: 'my cache item'\n};\nconst options = {\n    life: 60,   // set lifespan of one minute\n    tags: [ 'my-cache-tag', 'another-tag' ]\n};\n\ncache.set(key, item, options);\n\nconst cachedItem = cache.get(key); // depending on context this can either return cached data or null\n\nif (cachedItem) {\n    console.log(`Cached item: ${cachedItem.name}`);\n}\n\n// To demonstrate removal\nsetTimeout(() => {\n    cache.expire(key); // removes item with particular key\n    console.log(`Cache size after expiry: ${cache.size()}`);\n}, 1000); // Wait a bit to ensure async operation completes and cache is still there before expiry","lang":"javascript","description":"Demonstrates initializing the cache, setting a record with options (lifespan, tags), retrieving it, and then explicitly expiring it by key.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}