Registry / storage / feathers-hooks-rediscache

feathers-hooks-rediscache

JSON →
library1.1.5jsnpmunverified

A set of hooks for caching FeathersJS API endpoints with Redis. Version 1.1.5 (Feathers 3) and 0.3.6 (Feathers 2). Uses Redis for shared caching across cluster nodes, with per-request caching based on route params. Supports group cache busting and single-route purge. No recent updates, low maintenance activity. Different from in-memory caches because Redis cache is cluster-wide.

npm install feathers-hooks-rediscache
INSTALL
IMPORT
SIG · FEATHERS-HOOKS-RED
F
feathers-hooks-rediscache
storagejavascriptv1.1.5
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.

redisBeforeHook
import { redisBeforeHook } from 'feathers-hooks-rediscache'
const { redisBeforeHook } = require('feathers-hooks-rediscache')
ESM or CJS both work; default export is an object with hooks. For Feathers 2 use version 0.x.
redisAfterHook
import { redisAfterHook } from 'feathers-hooks-rediscache'
const redisAfterHook = require('feathers-hooks-rediscache').redisAfterHook
Named export; do not use default import.
hookCache
import { hookCache } from 'feathers-hooks-rediscache'
import hookCache from 'feathers-hooks-rediscache/hookCache'
hookCache is a function that returns a hook; pass duration in seconds as parameter.
hookRemoveCacheInformation
import { hookRemoveCacheInformation } from 'feathers-hooks-rediscache'
Removes cache metadata from response after caching.

Shows how to apply the before and after hooks to cache service responses with a 1-hour duration.

const feathers = require('@feathersjs/feathers'); const express = require('@feathersjs/express'); const memory = require('feathers-memory'); const { redisBeforeHook, redisAfterHook, hookCache } = require('feathers-hooks-rediscache'); const app = express(feathers()); app.configure(express.rest()); app.use('/messages', memory()); app.service('messages').hooks({ before: { find: [redisBeforeHook()] }, after: { find: [hookCache({duration: 3600}), redisAfterHook()] } }); app.listen(3030, () => console.log('Listening on 3030'));
Debug
Known issues
deprecatedVersions 0.x are deprecated; only receive critical fixes.
fix
Upgrade to 1.x for Feathers 3. If on Feathers 2, stick to 0.3.6 and pin exact.
affects: <1.0.0
gotchaCache keys include query strings; two requests with different params will be cached separately.
fix
Be aware of cache key explosion; use group clearing to invalidate related keys.
affects: >=0.0.0
gotchaGroup cache clearing is only HTTP based; not tested with sockets.
fix
Use HTTP requests to clear groups; consider custom hook if needed.
affects: >=0.0.0
gotchaDoes not support nested folder routes in versions >=1.0.0; use version 0.3.6 if needed.
fix
Downgrade to 0.3.6 or implement custom caching.
affects: >=1.0.0
breakingVersion 1.0.0 dropped support for nested route parsing; parseNestedRoutes config option is removed.
fix
If using nested routes, switch to version 0.3.6.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'feathers-hooks-rediscache'
Package not installed or wrong version for Feathers version.
fix
Run: npm install feathers-hooks-rediscache --save  (for Feathers 3) or npm install feathers-hooks-rediscache@0.3.6 --save-exact (for Feathers 2)
TypeError: redisBeforeHook is not a function
Using default import instead of named import.
fix
Use: const { redisBeforeHook } = require('feathers-hooks-rediscache');
Redis connection error: Error: connect ECONNREFUSED
Redis server not running or incorrect configuration.
fix
Ensure Redis is running and check config/default.json for host/port.
UnhandledPromiseRejectionWarning: Error: Cache key not found
Attempting to clear a cache key that does not exist.
fix
No fix needed unless the key should exist. The error is non-critical; consider ignoring.
Upgrade
Version history
1.1.5latest on npm
Audit
Dependencies
feathers-hooksoptionalPeer dependency for Feathers hooks system
redisrequiredRequired to connect to Redis server
Agent activity
30 hits · last 30 days
node
28
OpenAI (training)
1
Resources
feathers-hooks-rediscache — npm install feathers-hooks-rediscache · libregistry