Created
April 8, 2015 22:33
-
-
Save hobodave/2e674ab6d138656e3eb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sheen | |
include Celluloid | |
def initialize(name) | |
@name = name | |
end | |
def set_status(status) | |
@status = status | |
end | |
def report | |
Rails.cache.fetch(:report, expires_in: 20.seconds) do | |
puts "Taking a nap..." | |
sleep(5) | |
"#{@name} is #{@status}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So you want to cache the output of
future.report
and next time report is called, not actually run the method?