chilimatic / cache-component
cache component within the chilimatic framework
2.1.2
2018-06-10 16:53 UTC
Requires
- php: >=7.1
- chilimatic/interfaces-component: 2.*
Requires (Dev)
- phpunit/phpunit: 6.5.*
This package is auto-updated.
Last update: 2025-01-09 14:41:46 UTC
README
Currently there are 3 adapters:
Memcached, Apcu and Memory
It also comes with a singelton wrapper but you don't have to use it.
$cache = Cache::getInstance(['type' => chilimatic\lib\Cache\Engine\Adapter\Memory::class]);
If you want to use a Factory
$cache = CacheFactory::make(chilimatic\lib\Cache\Engine\Adapter\Memory::class);
And ofc you can access them directly
$cache = new chilimatic\lib\Cache\Engine\Adapter\Memory();
you can pass in arrays or stdClass it will transform it to an array anyway (nested too)
$cache = new chilimatic\lib\Cache\Engine\Adapter\Memcached([ 'server_list' => [[ 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 1 ]], 'options' => [ // the options are per instance not per connection! Memcached::OPT_HASH => Memcached::HASH_MURMUR ] ]);
more about the possible options http://php.net/manual/en/memcached.constants.php
$cache = new chilimatic\lib\Cache\Engine\Adapter\APCU();
one of the benefits of this library is that it actually allows you to see what theoretically stored within the caches
$cache = chilimatic\lib\Cache\Engine\Adapter\Memory(); var_dump($cache->listEntries());
it has 1 dependency the chilimatic interfaces.
if you want to know how things work I recommend looking at the tests :)