|  | 
| 1 |  | -# Stash | 
|  | 1 | +# Stash - A PHP Caching Library [](https://travis-ci.org/tedivm/Stash) | 
| 2 | 2 | 
 | 
| 3 |  | -[](https://travis-ci.org/tedivm/Stash) | 
| 4 | 3 | [](https://packagist.org/packages/tedivm/stash) | 
| 5 | 4 | [](https://packagist.org/packages/tedivm/stash) | 
| 6 |  | -[](https://bitdeli.com/free "Bitdeli Badge") | 
| 7 | 5 | 
 | 
| 8 | 6 | Stash makes it easy to speed up your code by caching the results of expensive | 
| 9 | 7 | functions or code. Certain actions, like database queries or calls to external | 
| 10 | 8 | APIs, take a lot of time to run but tend to have the same results over short | 
| 11 | 9 | periods of time. This makes it much more efficient to store the results and call | 
| 12 | 10 | them back up later. | 
| 13 | 11 | 
 | 
|  | 12 | +## Installing | 
|  | 13 | + | 
|  | 14 | +### Composer | 
|  | 15 | + | 
|  | 16 | +Installing Stash can be done through a variety of methods, although Composer is | 
|  | 17 | +recommended. | 
|  | 18 | + | 
|  | 19 | +Until Stash reaches a stable API with version 1.0 it is recommended that you | 
|  | 20 | +review changes before even Minor updates, although bug fixes will always be | 
|  | 21 | +backwards compatible. | 
|  | 22 | + | 
|  | 23 | +``` | 
|  | 24 | +"require": { | 
|  | 25 | + "tedivm/stash": "0.11.*" | 
|  | 26 | +} | 
|  | 27 | +``` | 
|  | 28 | + | 
|  | 29 | + | 
|  | 30 | +### Pear | 
|  | 31 | + | 
|  | 32 | +Stash is also available through Pear. | 
|  | 33 | + | 
|  | 34 | +``` | 
|  | 35 | +$ pear channel-discover pear.tedivm.com | 
|  | 36 | +$ pear install tedivm/Stash | 
|  | 37 | +``` | 
|  | 38 | + | 
|  | 39 | + | 
|  | 40 | +### Github | 
|  | 41 | + | 
|  | 42 | +Releases of Stash are available on [Github](https://github.com/tedivm/Stash/releases). | 
|  | 43 | + | 
|  | 44 | + | 
| 14 | 45 | ## Documentation | 
| 15 | 46 | 
 | 
| 16 |  | -Visit [stash.tedivm.com](http://stash.tedivm.com) for the current documentation. | 
|  | 47 | +Although this README contains some userful data there is a lot more information | 
|  | 48 | +at the main site,. [stash.tedivm.com](http://stash.tedivm.com). | 
| 17 | 49 | 
 | 
| 18 | 50 | The [development documentation](http://stash.tedivm.com/dev/) is available for | 
| 19 | 51 | testing new releases, but is not considered stable. | 
|  | 52 | + | 
|  | 53 | + | 
|  | 54 | +## Core Concepts | 
|  | 55 | + | 
|  | 56 | +### Main Classes | 
|  | 57 | + | 
|  | 58 | +Stash has three main components- a Pool class that represents a specific | 
|  | 59 | +grouping of cached objects, an Item class that provides access to individual | 
|  | 60 | +objects, and a series of Driver classes that allow Stash to interact with | 
|  | 61 | +caching systems. | 
|  | 62 | + | 
|  | 63 | +Each Driver is initialized and then passed into a Pool, at which point the | 
|  | 64 | +Developer can simply forget about it. Developers also have the option of using | 
|  | 65 | +multiple Drivers together by joining them with the Composite Driver. | 
|  | 66 | + | 
|  | 67 | +The Pool class allows developers to perform a number of tasks. There are a few | 
|  | 68 | +maintenance related tasks, such as running a "Purge" to allow backend systems to | 
|  | 69 | +perform maintenance tasks or set new logging or driver classes. The `Pool` also | 
|  | 70 | +can be used to create `Item` objects, singly or in groups. | 
|  | 71 | + | 
|  | 72 | +Each Item represents a single object inside the cache. It has a unique Key, | 
|  | 73 | +meaning that any two Item's created from the same Pool will contain the same | 
|  | 74 | +Value. An Item can set, get and remove a value from a caching system. | 
|  | 75 | + | 
|  | 76 | +### Keys | 
|  | 77 | + | 
|  | 78 | +A Key is a string that represents an Item in a caching system. At it's | 
|  | 79 | +simpliest, a key is an alphanumeric string and has a one to one relationship | 
|  | 80 | +with a value in the cache. | 
|  | 81 | + | 
|  | 82 | +Stash provides a feature known as "stacks" that allows developers to group | 
|  | 83 | +related Items together so they can be erased as a group. This is done by giving | 
|  | 84 | +Items a nested structure, similar to folders on a computer. Just like with | 
|  | 85 | +folders, this is represented by adding slashes to the name representing the file | 
|  | 86 | +or cached object. | 
|  | 87 | + | 
|  | 88 | +For example, a Key like "/models/users/34/profile" can allow developers to clear | 
|  | 89 | +the data for specific users using that user's id, or clear the data for all | 
|  | 90 | +users or even all models. It can also allow that developer to break up data into | 
|  | 91 | +specific pieces to only load what is needed. | 
|  | 92 | + | 
|  | 93 | +### Session Storage | 
|  | 94 | + | 
|  | 95 | +The provided Session class takes a Pool in it's constructor and can then be | 
|  | 96 | +registered as a Session Handler using the build in PHP methods, the | 
|  | 97 | +Session::registerHandler static function, or by using any framework that uses | 
|  | 98 | +the SessionHandlerInterface interface. | 
|  | 99 | + | 
|  | 100 | + | 
|  | 101 | +## Drivers | 
|  | 102 | + | 
|  | 103 | +Stash currently supports the following backends: | 
|  | 104 | + | 
|  | 105 | +* FileSystem | 
|  | 106 | +* Sqlite | 
|  | 107 | +* APC | 
|  | 108 | +* Xcache (experimental) | 
|  | 109 | +* Memcached | 
|  | 110 | +* Redis | 
|  | 111 | +* Ephemeral (runtime only) | 
|  | 112 | + | 
|  | 113 | +Stash also supports a specialized "Composite" Driver which can contain any | 
|  | 114 | +number of the above drivers. This allows developers to created multitiered | 
|  | 115 | +drivers that use a variety of back ends. | 
|  | 116 | + | 
|  | 117 | + | 
|  | 118 | +## License | 
|  | 119 | + | 
|  | 120 | +Monolog is licensed under the BSD License. See the LICENSE file for details. | 
0 commit comments