PHP code example of kuikui / memcache-service-provider

1. Go to this page and download the library: Download kuikui/memcache-service-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kuikui / memcache-service-provider example snippets


$app->register(new KuiKui\MemcacheServiceProvider\ServiceProvider());

$app->register(new KuiKui\MemcacheServiceProvider\ServiceProvider());

// Simple use
$app['memcache']->set('key', 'value');
$value = $app['memcache']->get('key');
$app['memcache']->delete('key');

// Advanced use : use \Closure to generate default value and save it during a retrieve process
$value = $app['memcache']->get('key', function() use ($app) {
    return $app['some_other_service']->getData();
});


$app['memcache.connections'] = array(
    array('127.0.0.1', 11211),
    array('10.0.1.118', 12345)
; // default: array('127.0.0.1', 11211)

$app['memcache.class'] = '\Memcached'; // default: '\Memcache'

$app['memcache.wrapper'] = '\My\Custom\Wrapper';

$app['memcache.wrapper'] = false;

$app['memcache.default_duration'] = 60; // default: 0 (no limit)
shell
$ curl -sS http://getcomposer.org/installer | php
$ php composer.phar install