Add store/layer identification to cache hooks for multi-store setups
Description
When using cache-manager with primary and secondary stores, there's currently no way to identify which specific store/layer served a cache hit when using the built-in multi-store functionality. This makes it impossible to implement proper monitoring and metrics collection per cache layer.
Current Behavior
When configuring cache-manager with primary and secondary stores, The emitted hooks are not specific to the cache layer they are associated with. This makes it difficult to track and monitor the performance of each layer.
Use Case
This feature is essential for:
- Performance Monitoring - Understanding cache layer utilization and hit rates
- Cost Optimization - Identifying if expensive layers (e.g., Redis) are being utilized effectively
- Debugging - Tracing which layer served specific requests
- Capacity Planning - Making informed decisions about cache layer sizing
@tshtark - Thanks for submitting this. Right now we just use event emitter here to send out the store such as on get
eventEmitter.emit('get', {key, error, store}); where right now we are doing eventEmitter.emit('get', {key, error});
@tshtark - moving this to a vote and will keep live for 60 days. If we get enough people interested we will look at add this. If you want to do a pull request more than happy to help you on it. Just let me know
Hey Guys 👋 I’ve opened a PR that implements this enhancement. It adds primary / secondary:N store identifiers to event payloads so users can track which layer served a cache hit.
These are rolling out today.