Rails cache do inside module
Hot can I use cache do command inside module?
Example
module MyModule
def self.some_method(str)
cache str do
开发者_JAVA技巧... some code ...
end
end
end
Thx!
Assuming you're using Rails, you can do it like so:
module MyModule
def self.some_method(str)
Rails.cache.fetch(str) do
# ...
end
end
end
精彩评论