Registry / database / bajo-cache

bajo-cache

JSON →
library2.7.0jsnpmunverified

Universal Cache Engine for the Bajo Framework, version 2.7.0. Provides a modular caching abstraction supporting multiple backends (memory, Redis, filesystem) with configurable TTL, namespace isolation, and error handling. Designed specifically for Bajo-based applications but can be used standalone. Released under MIT license with low release cadence. Differentiates by deep integration with Bajo's plugin system and declarative config-driven setup.

npm install bajo-cache
INSTALL
IMPORT
SIG · BAJO-CACHE
B
bajo-cache
databasejavascriptv2.7.0
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.

bajoCache
import bajoCache from 'bajo-cache'
Default export is the factory function to create a cache instance.
Cache
import { Cache } from 'bajo-cache'
Named export for the Cache class (available since v2.0).
clearCache
import { clearCache } from 'bajo-cache'
Utility function to clear all cache namespaces.

Shows creating a cache instance with memory backend, set/get/delete operations, and switching to Redis driver.

import bajoCache from 'bajo-cache'; const cache = bajoCache({ namespace: 'myapp', ttl: 300 }); await cache.set('user:1', { name: 'Alice' }); const user = await cache.get('user:1'); console.log(user); // { name: 'Alice' } await cache.del('user:1'); // Using with Redis backend const redisCache = bajoCache({ driver: 'redis', redis: { url: process.env.REDIS_URL ?? '' } }); await redisCache.set('key', 'value'); const val = await redisCache.get('key');
Debug
Known issues
breakingIn v2.0, the driver option changed from 'memory' (default) to 'none'. To use memory, explicitly set driver: 'memory'.
fix
Set driver: 'memory' in options if using default memory cache.
affects: >=2.0 <2.0
gotchaCalling get() on a missing key returns undefined, not null. Use strict equality check.
fix
Check if (val === undefined) instead of if (!val).
affects: >=1.0
deprecatedThe 'filesystem' driver is deprecated since v2.5 and will be removed in v3.0.
fix
Migrate to 'redis' or another supported driver.
affects: >=2.5
Errors
Common errors & fixes
Error: Cannot find module 'bajo-cache'
Package not installed or not in node_modules.
fix
Run 'npm install bajo-cache' and ensure your project has a package.json.
TypeError: bajoCache is not a function
Default import used incorrectly in CommonJS or ES module context mismatch.
fix
If using CommonJS, use 'const bajoCache = require('bajo-cache').default;' or use ES import syntax.
Error: Driver 'redis' not available. Install redis driver or use a different driver.
Redis driver dependencies not installed.
fix
Run 'npm install ioredis' (or the required Redis client) and ensure it's in your project.
Upgrade
Version history
2.7.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
bajo-cache — npm install bajo-cache · libregistry