fast-cache icon indicating copy to clipboard operation
fast-cache copied to clipboard

Separate cache items by source?

Open pprochnau-ipipeline opened this issue 3 months ago • 1 comments

Just started using your library and like it a lot. However, found a scenario that I'm not sure how to handle.

Environment: We have a number of APIs that service multiple databases, based on data in the request. We are caching certain data in memory from each of the databases. Currently we are adding the database identifier as part of the key into the cache.

The issue arises when we find from the DB that we need to flush our cache. I can't think of a way to clear the cache for only entries specific to that DB, other than iterating through the entire cache and checking each key to see if it matches the DB I'm interested in.

Is there a way to isolate (or identify) entries from a specific source? E.g., have a cache for DB1, another for DB2, etc., so that I can easily flush one of them.

Thanks for your work on this library!

pprochnau-ipipeline avatar Mar 20 '24 18:03 pprochnau-ipipeline