A Redis database component for the blue-fish framework, built on ioredis. Provides caching, message queuing, cron jobs, and distributed locks. Written in TypeScript with full type definitions. Current version 1.0.4 (released 2025). The package appears to be a fork or continuation of coa-redis, with a focus on bug fixes. Lightweight (few hundred lines) with no external dependencies beyond ioredis and blue-fish core.
npm install blue-fish-redisNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates RedisBin configuration, cache set/get/delete, message queue push/listen, and distributed lock acquire/release.
Replace 'coa-redis' with 'blue-fish-redis' in package.json and imports. Review the coa-redis API for any changes.
Always provide a namespace string as the first argument to cache methods, e.g., cache.set('users', 'id', value, ttl).Remove 'prefix' from config and use the 'nsp' parameter in RedisCache methods.
Instantiate RedisCron with (queueWorker, version) where version is the application's semantic version (e.g., '1.2.3').
Ensure worker.on('messageName', callback) is registered before producing messages to avoid missed events.Use constructor with 'new' keyword. For type annotations, you may use the class name as a type (e.g., let cache: RedisCache).
Always set an appropriate TTL. Consider using Lua scripts for atomic unlock if race conditions are a concern.
Use: import { RedisCache } from 'blue-fish-redis'Provide a namespace string as the first argument: cache.set('my-namespace', 'key', value, ttl)new RedisCron(queueWorker, '1.0.0') where the second argument is the app version string.
Use a positive TTL (in seconds): await lock.lock('resource', 30)