Rails 2.1 brings some new caching features which makes it very easy to cache any values including models. See how in this episode.
# script/console
Rails.cache.write('date', Date.today)
Rails.cache.read('date')
Rails.cache.fetch('time') { Time.now }
cache = ActiveSupport::Cache.lookup_store(:mem_cache_store)
cache.fetch('time') { Time.now }
c = Category.first
c.cache_key # => "categories/1-20080622195243"
# models/category.rb
def self.all_cached
Rails.cache.fetch('Category.all') { all }
end
# config/environments/production.rb
config.cache_store = :memory_store
config.cache_store = :file_store, '/path/to/cache'
config.cache_store = :mem_cache_store
config.cache_store = :mem_cache_store, { :namespace => 'storeapp' }
config.cache_store = :mem_cache_store, '123.456.78.9:1001', '123.456.78.9:1002'
分享到:
相关推荐
Caching your GitHub password in Git 保存你的 Github 密码如果是 使用 HTTPS 来复制 github 项目库, 可
this work, we propose a novel caching strategy in which a dynamic result cache is split into two layers: an HTML cache and a docID cache. The HTML cache in the first layer stores the result pages ...
Edge Caching in Blockchain Empowered 6G
Edge Caching in Blockchain Empowered 6G.pdf
We still start with a step-by-step walkthrough of building a real application, and in-depth chapters look at the built-in Rails features. This edition now gives new Ruby and Rails users more ...
# mart caching of frequently used applications and files for maximum performance; # Supports both USB and non-USB removable media devices (CF, SD/SDHC, MMC, xD and other memory cards), as well as ...
The World Wide Web can be considered as a large distributed information system that provides access to shared data ...in Web caching systems. Finally, we discuss the research frontier in Web caching.
You will find a thorough introduction to both Ruby and Rails in this book. You'll get the easy instructions for acquiring and installing both; understand the nature of conditionals, loops, methods, ...
Create reusable components that bring Bootstrap and Angular together and effectively use materialized views for caching within Postgres. Get your front end working with Webpack, use Postgres' ...
Demo of ehCache distributed caching with terracotta in glassFish v3 可以参考:http://blog.csdn.net/guobin0719/archive/2011/04/25/6361940.aspx
Enyim.Caching.dll 32位 Enyim.Caching.dll 32位 Enyim.Caching.dll 32位
NULL 博文链接:https://liang-wenfu.iteye.com/blog/1017556
Issues in Cooperative Proxy Caching Section 9.3. Location Management Section 9.4. Caching on a Global Scale: Proxy Pruning Section 9.5. An Overview of Existing Platforms Section 9.6. Summary ...
这是一个关于在Windows Azure上使用Cache的ppt,对比了Cache Service、Redis、MemCache等等。
Rails 4 introduces a number of user-facing changes, and the ebook has been updated to match all the latest changes and new best practices in Rails. This includes full support for Ruby 2.0, controller ...
Caching is a popular technique for reducing both server load and user response time in distributed systems. In this paper, we consider the question of whether caching might be effective for search ...
We study the caching of query result pages inWeb search en- gines. Popular search engines receive millions of queries per day, and ecient policies for caching query results may en- able them to lower ...