taskrabbit/storehouse — pull request #5 by mnelson (2012-11-19 21:15:12+00:00)
Title: Rewrite Tailored to Simplicity

### Overview

The old storehouse was too complicated. Logic was floating around in the wrong places, it was dependent on Rails, and it was built with the wrong focus.

This version of storehouse provides a simple rack gem which only utilizes headers to integrate it's caching strategy. It's also focused on using redis, not riak since TaskRabbit is moving to that. A riak connection adapter can easily be built with the new architecture.

To activate storehouse's caching strategy, simply pass headers down as part of your app's response:

````ruby
response.headers['X-Storehouse'] = '1'
````

Expirations can be sent via the headers:

````ruby
response.headers['X-Storehouse-Expires-At'] = 4.hours.from_now.to_i.to_s
````

Distribution of the cache to disk can still be done by passing:

````ruby
response.headers['X-Storehouse-Distribute'] = '1'
````

This distribution header will be stored in the cache and sent along with the next request (potentially on a different server) and distributed as such.

### storehouse.yml

Storehouse configures itself via an environment-scoped config file. Place `storehouse.yml` in your app/config directory (if you have one) or provide the config location via the `ENV['STOREHOUSE_ROOT']`. Storehouse will attempt to figure out your app root via environment variables such as `RAILS_ROOT`, `RACK_ROOT`, or constants such as `Rails`. It will also determine environment in a similar manner.

The config file should look like (all options except `backend` are optional):

````yaml
development:
enabled: true # include this line to enable storehouse
backend: redis # choose the backend your app will use
namespace: myappprod # the namespace which all keys should be prefixed by
connections: # the connection information passed to the backend
host: 10.0.0.1
port: 6380

panic_path: 'public/panic.txt' # the relative path (from project root) for a panic file
ignore_params: false # serve cached content to requests with query strings
postpone: false # when encountering an expired page, defer the expiration for other users
serve_expired_content_to: Bot # the user agent matcher for serving expired content
reheat_param: reheat_cache # the param to pass to reheat the cache manually
````