Rails 2.1 Caching Walkthrough

No Comments - Post one!
By Peter Cooper on June 18th, 2008 in Tips, Tutorials

Rob Anderton has put together an easy-to-read walkthrough of some of the new caching features in Rails 2.1. One of the coolest new features is that Rails provides an abstraction to using the back-end caching features (whether ultimately provided by file stores or memcached):

# Write a string to the cache
Rails.cache.write('test_key', 'test_value')
=> true

# Read it back in
Rails.cache.read('test_key')
=> 'test_value'

# Delete the item
Rails.cache.delete('test_key')
=> true

Leave a Reply