Skip to content

Instantly share code, notes, and snippets.

@macournoyer
Created February 18, 2009 18:35
Show Gist options
  • Select an option

  • Save macournoyer/66465 to your computer and use it in GitHub Desktop.

Select an option

Save macournoyer/66465 to your computer and use it in GitHub Desktop.
def self.memoize_with_memcache(name)
define_method "#{name}_with_memo" do
key = [self.class.name, id.to_s] * '/'
Cache.get(key) || Cache.put(key, name_without_memo)
end
alias_method_chain :name, :memo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment