Created
February 13, 2012 16:04
-
-
Save DavidQL/1817875 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 User | |
def increment_memcache_iterator | |
Rails.cache.write("user-#{self.id}-memcache-iterator", self.memcache_iterator + 1) | |
end | |
def memcache_iterator | |
# fetch the user's memcache key | |
# If there isn't one yet, assign it a random integer between 0 and 10 | |
Rails.cache.fetch("user-#{self.id}-memcache-iterator") { rand(10) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment