Transparent client-side caching of HTTP requests (heap, file, memcache). Built-in support for RestClient. Built upon Rack::Cache. [will be replaced by http://github.com/crohr/rest-client-components]
MIT License
= cacheability
A gem that makes client-side caching of HTTP requests a no-brainer. It is built upon the Rack:Cache gem from Ryan Tomayko.
Cached data can be stored in heap, file or memcached. See the rack-cache[http://tomayko.com/src/rack-cache] documentation for more information.
Currently, cacheability comes with a rest-client[http://github.com/archiloque/rest-client] adapter, but the principle is easily applicable to other HTTP libraries.
= Installation
gem install cacheability
= Usage Using the rest-client HTTP library, you just need to require the restclient adapter and enable the caching component:
require 'cacheability/restclient'
RestClient.enable :caching, :metastore => 'file:/tmp/cache/meta', :entitystore => 'file:/tmp/cache/body'
RestClient.get 'http://some/cacheable/resource'
resource = RestClient::Resource.new('http://some/cacheable/resource')
resource.get # get from origin server, and cache if possible resource.get # get from cache, if still fresh. resource.put(...) # will automatically invalidate the cache, so that a subsequent GET request on the same resource does not return the cached resource resource.get # get from origin server, and cache if possible
resource.get(:cache_control => 'no-cache') # explicitly tells to bypass the cache, requires rack-cache >= 0.5 and :allow_reload => true option
resource.delete(...) # will invalidate the cache resource.get # should raise a RestClient::ResourceNotFound exception
Now, you just need to make your resources cacheable, so unless you've already taken care of that, do yourself a favor and read:
= Supported libraries
= Dependencies
= COPYRIGHT
Copyright (c) 2008 Cyril Rohr. See LICENSE for details.