jnunemaker/flipper — pull request #18 by jnunemaker (2013-02-15 22:39:23+00:00)
Title: Adapter Overhaul

Initially, I wanted adapters to be as dump as possible so they were super easy to write. Unfortunately, making them super dumb also made them super hard to optimize the number of network calls they require to check a feature.

This PR changes that. Previously adapters had to respond to the following methods:

* read(key)
* write(key, value)
* delete(key)
* set_members(key)
* set_add(key, value)
* set_delete(key, value)

Now, instead of abstracting the data type, I pass the feature I want to get, or the feature, gate, and thing I want to enable.

* get(feature) # => should return hash of gate keys => gate values.
* enable(feature, gate, thing)
* disable(feature, gate, thing)

I've updated the redis adapter to use a hash per feature and the mongo adapter to use a document per feature. In combination with the memoizer middleware, which memoizes feature gets for the length of the request, this means that checking a given feature will only add one network call, no matter how many times you check it.