I have the method
def self.fetch(key, &block)
begin
Rails.cache.fetch(key, block)
rescue Redis::CommandError => e
raise unless e.message == "OOM command not allowed when used memory > 'maxmemory'."
Utils.log_exception ex
yield
end
end
This fails on line 3 with the error
ArgumentError: Missing block: Calling
Cache#fetchwithforce: truerequires a block.
I'm not sure if passing block in as a parameter like that is the correct way but I couldn't see another way.
What is the correct way to pass a variable containing a block to a method?