Created
February 22, 2013 18:52
-
-
Save mb-dev/5015674 to your computer and use it in GitHub Desktop.
Dogpile effect - capture a lock using memcache
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
| if result.blank? | |
| Rails.cache.write(name + ':refresh-thread', 0, raw: true, unless_exist: true, expires_in: 5.seconds) | |
| if Rails.cache.increment(name + ':refresh-thread') == 1 | |
| # we are the first visitor | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment