Cache library. Implements different adapters.
- PHP >= 5.4
- predis/predis ~1.0
$ composer require kasseler/cache
$cache = new Cache(new ArrayCache());
$cache->set('foo', [1,2,3,4,5]);
if ($cache->has('foo')) {
var_export($cache->get('foo')->data());
}
$cache->drop();
$cache = new Cache(new ArrayCache());
$cache = new Cache(new ApcCache());
$cache = new Cache(new FileCache());
$cache = new Cache(new MemcacheCache());
$cache = new Cache(new MemcachedCache());
$cache = new Cache(new MongoDBCache());
$cache = new Cache(new PredisCache());
$cache = new Cache(new RedisCache());
$cache = new Cache(new SessionCache());
$cache = new Cache(new SQLite3Cache());
$cache = new Cache(new VoidCache());
$cache = new Cache(new XcacheCache());
Test was conducted on php 5.6.
10K set | 10K set | 10K get | 10K get | 10K has | 10K has | |
---|---|---|---|---|---|---|
time, sec | memory, Kb | time, sec | memory, Kb | time, sec | memory, Kb | |
Session | 1,0591 | 5136,7890 | 104,262 | 11933,5893 | 68,2759 | 11933,5781 |
File | 55,3532 | 19,90 | 11,2696 | 20,0781 | 1,9091 | 19,0937 |
Mongo | 16,4049 | 19,3671 | 13,9658 | 20,3593 | 13,9008 | 19,375 |
Predis | 2,2291 | 138,7343 | 2,1721 | 137,625 | 1,6831 | 133,1796 |
Redis | 1,2731 | 27,1484 | 1,1151 | 27,1953 | 0,786 | 22,6562 |
Memcache | 1,25 | 27,3359 | 1,8681 | 27,7890 | 0,814 | 23,1953 |
APC | 0,9251 | 17,7265 | 1,1331 | 17,8046 | 0,441 | 13,226 |
Xcache | 0,832 | 17,9140 | 0,9731 | 17,0468 | 0,439 | 13,4531 |
Void | 0,147 | 17,3593 | 0,005 | 13,0390 | 0,174 | 13,1718 |