duo-cache is a caching library built on LevelDB, designed to speed up Duo builds by storing data on disk. Version 2.1.2 is the latest stable release; the project appears inactive with no recent commits (last updated around 2015). It integrates with Duo's build pipeline to cache processed files, plugin results, and dependency scans. Unlike simple in-memory caches, it persists data across runs using LevelDB. However, it depends on the now-deprecated `level` npm package and is not actively maintained, making it unsuitable for new projects. Key differentiators: uses LevelDB for disk-backed persistence, supports both file-level and plugin-level caching with flexible key structures.
npm install duo-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of duo-cache: creating a cache instance, setting/getting files, using plugin caching with custom keys, and cleaning up the database.
Consider migrating to `level` v8+ (`npm i level`) or use a different cache solution such as `cache-manager` or `node-cache`.
Wrap calls in a generator function and use `co()` or migrate to a modern async library. Example: `co(function*() { ... })`.Only call `clean()` when you explicitly intend to remove the cache directory. Use `fs.unlink` or `level.destroy` for safer cleanup if needed.
Loop over files individually or use `update()` to save a mapping object.
Ensure the plugin name is consistent (e.g., package name). There is no validation, so typos silently create separate cache entries.
Use `import Cache from 'duo-cache'` (ESM) or `const Cache = require('duo-cache')` (CommonJS).Install level: `npm install level` or ensure it's in your package.json dependencies.
Wrap the code in a generator function: `co(function*() { ... yield cache.file('id'); ... })`.Ensure you call `new Cache(location)` and that the location is writable. If the database is closed, create a new instance.