Skip to content

Instantly share code, notes, and snippets.

@boffbowsh
Created February 19, 2012 11:08
Show Gist options
  • Select an option

  • Save boffbowsh/1863198 to your computer and use it in GitHub Desktop.

Select an option

Save boffbowsh/1863198 to your computer and use it in GitHub Desktop.
class MyModel < ActiveRecord::Base
# column :file
def file= contents
Redis[(key = generate_key)] = contents
write_attribute(:file, key)
end
def file
@file_contents ||= Redis[read_attribute(:file)]
end
private
def generate_key
# Some logic here
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment