PHP code example of olegkishko / tt_memc

1. Go to this page and download the library: Download olegkishko/tt_memc 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/ */

    

olegkishko / tt_memc example snippets


use tt_memc\CacheService;
use tt_memc\Driver\MemcachedDriver;

$cache = new CacheService(new MemcachedDriver());

// set values
$cache->set('int', 100);
$cache->set('string', 'Hello');
$cache->set('array', [0 => 'a']);
$cache->set('object', new stdClass());

// get values
var_dump($cache->get('int'));
var_dump($cache->get('string'));
var_dump($cache->get('array'));
var_dump($cache->get('object'));

// delete values
$cache->delete('int');
$cache->delete('string');
$cache->delete('array');
$cache->delete('object');