Skip to content

Instantly share code, notes, and snippets.

@ryana
Created July 7, 2011 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryana/1068651 to your computer and use it in GitHub Desktop.
Save ryana/1068651 to your computer and use it in GitHub Desktop.
Thoughts on reloading github.com/trada/dada.git configs w/ a memcache triggers
# Note: not tested at all
module Dada
attr_accessor :config_reload_timestamp
def dalli
@dalli ||= Dalli::Client.new(client_args)
end
def check_config_timestamp
# Check a memcache value to see if it's been changed since the last time we reloaded
if dalli.get('dada-reload-timestamp').to_f <= self.config_reload_timestamp.to_f
# if it is, reload & save new timestamp
reload_config
self.config_reload_timestamp = Time.now.to_f
end
end
def is_enabled?(*args)
check_config_timestamp
old_is_enabled?(*args)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment