For Redis:
As of Rails 7.1.0.beta1, Rails.cache.redis
always returns a Connection Pool (https://github.com/mperham/connection_pool), so the access to the Redis client and consequently to the keys are now different:
Rails.cache.redis.with do |redis_client|
redis_client.keys
end