Skip to content

Instantly share code, notes, and snippets.

@mb-dev
Created February 22, 2013 18:52
Show Gist options
  • Select an option

  • Save mb-dev/5015674 to your computer and use it in GitHub Desktop.

Select an option

Save mb-dev/5015674 to your computer and use it in GitHub Desktop.
Dogpile effect - capture a lock using memcache
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