In brief i’m writing a plugin for a Rails app and I want to cache the data the plugin generates, however I want the ability to delete the cached items should I need to do so.
e.g.
Rails.cache.write("data_1", "the data")
Rails.cache.write("data_2", "the data")
Rails.cache.write("data_3", "the data")
What should I be calling to fetch all keys that match the regex /^data_/ so I can delete them?
I tried:
Rails.cache.fetch(/^data_/)
Rails.cache.read(/^data_/)
Any help/pointers would be greatly appreciated.
You can use
.match. So something like this should work: