Skip to content

Instantly share code, notes, and snippets.

@coalwater
Created April 2, 2015 16:06
Show Gist options
  • Save coalwater/e382b9d3fdda2e90c5ab to your computer and use it in GitHub Desktop.
Save coalwater/e382b9d3fdda2e90c5ab to your computer and use it in GitHub Desktop.
Using rails low level caching
Rails.cache.read 'my_caching_key'
Rails.cache.write 'my_caching_key', some_data
Rails.cache.fetch('some_key', expires_in: 10.minutes) do
some_caculation
end
Rails.cache.read({key: 'important_data', owner: @user})
Rails.cache.write(['some_data', @user], some_data)
Rails.cache.write({key: 'important_data', owner: @user}, some_data)
Rails.cache.write 'my_caching_key', some_data, expires_in: 1.hour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment