Download the PHP package corneltek/universal-cache without Composer
On this page you can find all versions of the php package corneltek/universal-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download corneltek/universal-cache
More information about corneltek/universal-cache
Files in corneltek/universal-cache
Package universal-cache
Short Description A Generic PHP Cache Interface with Cascade Caching
License MIT
Homepage http://github.com/corneltek/UniversalCache
Informations about the package universal-cache
UniversalCache
A Generic PHP Cache Interface with Cascade Caching.
DESCRIPTION
This package was inspired by a Perl module - Cache::Cascade.
In a multiprocess, and especially a multiserver application caching is a very effective means of improving results.
The tradeoff of increasing the scale of the caching is in added complexity. For example, caching in a FastMmap based storage is much slower than using a memory based cache, because pages must be locked to ensure that no corruption will happen. Likewise Memcached is even more overhead than FastMmap because it is network bound, and uses blocking IO (on the client side).
This module attempts to make a transparent cascade of caches using several backends.
The idea is to search from the cheapest backend to the most expensive, and depending on the options also cache results in the cheaper backends.
The benefits of using a cascade are that if the chance of a hit is much higher in a slow cache, but checking a cheap cache is negligible in comparison, we may already have the result we want in the cheap cache. Configure your expiration policy so that there is approximately an order of magnitude better probability of cache hits (bigger cache) for each level of the cascade.
INSTALL
composer require corneltek/universal-cache
UniversalCache
UniversalCache class provides a consistent interface to operate on different cache backend, you may put the fastest cache backend on the first position, so that you can fetch the cache very quickly when there is a fresh cache in the fastest storage.
ApcuCache
ArrayCache
ArrayCache implements a pure php based cache, the cache is not persistent between different request. However, it made the request-wide cache simple.
MemcacheCache
RedisCache
FileSystemCache
Hacking
Install dependencies
composer install --prefer-source
Install redis extension
phpbrew ext install github:phpredis/phpredis php7
Install memcached extension
phpbrew ext install github:php-memcached-dev/php-memcached php7 -- --disable-memcached-sasl
Install APCu extension
phpbrew ext install github:krakjoe/apcu
Be sure to enable apcu and cli mode
apc.enabled=1
apc.enable_cli=1
Run tests
phpunit
LICENSE
This package is released under MIT license.