Redis cache does not support ^ in the delete_matched definition
When running a clear_cache, the ^ does not seem to supported
In Redis cache store, the pattern used is sent to scan
https://github.com/rails/rails/blob/main/activesupport/lib/active_support/cache/redis_cache_store.rb#L198
Trying to rerun it as close as possible to redis, we notice the ^ blocks retrieval of keys
Example:
r.scan(0, :match => "deal/*", count: 100)
=>
["476",
["deal/product/all/{:params=>{:universe_id=>2,:q=>{:published_eq=>true}}}",
"deal/category/5/relevant-products-for-newborn",
"deal/brand/25",
"deal/product/all/{:params=>{:category_id=>6,:q=>{:published_eq=>true}}}",
"deal/product/all/{:params=>{:category_id=>11,:q=>{:published_eq=>true}}}",
"deal/universe/all",
"deal/product/all/{:params=>{:category_id=>4,:q=>{:published_eq=>true}}}",
"deal/category/11/relevant-products-for-newborn",
"deal/brand/8",
"deal/product/all/{:params=>{:category_id=>15,:q=>{:published_eq=>true}}}",
"deal/brand/all/{:params=>{:q=>{:published_eq=>true,:random=>true}}}",
"deal/product/all/{:params=>{:category_id=>9,:q=>{:published_eq=>true}}}",
"deal/brand/21",
"deal/brand/4",
"deal/brand/13",
"deal/brand/16",
"deal/brand/12"]]
> r.scan(0, :match => "^deal/*", count: 100)
=> ["476", []]
Ah so then https://github.com/mhgbrown/cached_resource/blob/a2d1b33e260be60e12d7a3bbb662d62e102065b5/lib/cached_resource/caching.rb#L151 does not work.
So for Redis, we should omit the ^? Does that sound right?
Yup, that sounds about right
Will patch this :)
Done https://github.com/mhgbrown/cached_resource/pull/67