Basic object cache with `get`, `set`, `del`, and `has` methods for Node.js/JavaScript projects. Version 4.0.2 (latest stable, 2023-09) provides a simple in-memory cache with event emission and support for dot-notation keys. It is part of the 'base' ecosystem and is dependency-free. Unlike more complex caching solutions, it offers minimal overhead and is ideal for small-scale or temporary caching needs. The release cadence is low (sporadic updates), and it is considered stable and maintained.
npm install cache-baseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: creating a cache, setting/getting with dot-notation, checking existence, deleting, setting default values, listening to events, and the prime method.
Avoid using keys like 'toString', 'constructor', etc. Sanitize keys if they come from untrusted sources.
Always use `set`, `del`, `prime` etc. to manipulate the cache instead of directly altering `cache.cache`.
Understand that defaults are only consulted when the key is absent from the cache. To clear a default, use `app.del(key)` or set the key to undefined.
Pass a single object or key-value pair; avoid passing arrays unless you intend to merge multiple objects.
Use `const CacheBase = require('cache-base').default` or configure webpack to handle CommonJS properly.Run `npm install cache-base` and ensure `require('cache-base')` is used (no subpath).Ensure you are using cache-base v4.0.2 or later, or check that cache-base is correctly instantiated.
No dependency data recorded yet.