Allow to filter which entries to cache
I'm looking for a way to only cache names for a given domain. So I'm thinking having a filter option that takes a regular expression for example, if one wants to cache only hostnames with the example.org domain :
{ filter: /example.org$/ }
Would you take a pull request that implements this ? (Or do you have another suggestion to do the same ?)
(Oy, sorry for taking so long to respond.)
Yes, pull requests are most appreciated. A filter configuration sounds like a great way to do this. Hmm... perhaps call it cacheOnly so that it's a bit more self-documenting.
It would make sense to implement it in the cache module, so that cache.set checks if the key matches the filter. But it would not play well with the reverse method :/
Could also write a wrapper around cache.set and call it for all methods but reverse ?
Thoughts ?