tedivm/Stash — pull request #34 by jhallbachner (2012-04-22 08:15:46+00:00)
Title: Implemented CompositeHandler and InvocationStrategies

[![Build Status](https://secure.travis-ci.org/jhallbachner/Stash.png?branch=strategies)](http://travis-ci.org/jhallbachner/Stash)

This branch implements the InvocationStrategy system as discussed in issue #23. Some notes:

* I implemented two strategies: FallbackStrategy, which imitates the old MultiHandler behavior, and DataSizeStrategy, which sorts data into different handlers based on its size.
* The third strategy suggested in the original issue involves moving on from each handler when it's "full," but currently I'm not sure our handlers provide the information necessary to implement a robust version of this strategy.
* DataSizeStrategy currently uses either strlen($data) or strlen(serialize($data)) to determine the "size" of what's being stored; this probably needs to be improved.
* Arrays of handlers should be associative, with names given to each handler. Currently only DataSizeStrategy actually relies on this; FallbackStrategy simply uses the natural ordering of the handlers in the array, as with the old MultiHandler.
* Because CompositeHandler is itself a handler, complex behavioral chains are possible here -- with the current strategies, you could create a system that does fallback storage on two units: a size-split APC/memcache "handler" and a SQLite handler, for example.