Created
April 2, 2015 16:06
-
-
Save coalwater/e382b9d3fdda2e90c5ab to your computer and use it in GitHub Desktop.
Using rails low level caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.cache.read 'my_caching_key' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.cache.write 'my_caching_key', some_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.cache.fetch('some_key', expires_in: 10.minutes) do | |
some_caculation | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.cache.read({key: 'important_data', owner: @user}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.cache.write(['some_data', @user], some_data) | |
Rails.cache.write({key: 'important_data', owner: @user}, some_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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