mcache - php cache wrapper library
Install through composer package manager. Find it on packagist.
composer require g4/mcache
<?php
$driverName = 'Libmemcached';
$options = array(
'servers' => array(
'127.0.0.1:11211'
);
);
$prefix = 'my_prefix';
$mcache = \G4\Mcache\McacheFactory::createInstance($driverName, $options, $prefix);
<?php
$driverName = 'Couchbase';
$options = array(
'bucket' => 'my_bucket',
'servers' => array(
'127.0.0.1:8091'
);
);
$prefix = 'my_prefix';
$mcache = \G4\Mcache\McacheFactory::createInstance($driverName, $options, $prefix);
* bucket - string
* servers - array
* user - string
* pass - string
* persistent - bool
* timeout - int (default 2500000)
<?php
// Get from cache
$value = $mcache
->key('my_key')
->get();
// Save to cache
$mcache
->key('my_key')
->value('my_value')
->set();
// Sava to cache with expiration
$mcache
->key('my_key')
->value('my_value')
->expiration(3600) // in seconds (default 0)
->set();
// Delete from cache
$mcache
->key('my_key')
->delete();
// Replace a value
$mcache
->key('my_key')
->value('my_value')
->replace();
$ make install
$ make test
(The MIT License) see LICENSE file for details...