PHP code example of pavlyshyn / cache

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

    

pavlyshyn / cache example snippets


use Pavlyshyn\Cache;
use Pavlyshyn\Cache\Adapter\File;

$adapter = new File(__DIR__ . '/tmp');
$cache = new Cache($adapter);

$cache->set('key', 'value');
var_dump($cache->get('key'));

$cache->set($key, $value);

$cache->get($key);

$cache->exists($key);

$cache->remove($key);

$cache->clear();

use Pavlyshyn\Cache\Adapter\Memcache;

$adapter = new Memcache('127.0.0.1', 11211);

use Pavlyshyn\Cache\Adapter\Apc;

$adapter = new Apc();

use Pavlyshyn\Cache\Adapter\Predis;

$adapter = new Predis();

OR

$adapter = new Predis([
    'scheme' => 'tcp',
    'host'   => '10.0.0.1',
    'port'   => 6379,
]);

OR

$adapter = new Predis('tcp://10.0.0.1:6379');

use Pavlyshyn\Cache\Adapter\XCache;

$adapter = new XCache('admin', '');

use Pavlyshyn\Cache\Adapter\Memory;

$adapter = new Memory();

phpunit --bootstrap vendor/autoload.php  tests/Adapter/ApcTest
phpunit --bootstrap vendor/autoload.php  tests/Adapter/MemcacheTest
phpunit --bootstrap vendor/autoload.php  tests/Adapter/XCacheTest
phpunit --bootstrap vendor/autoload.php  tests/Adapter/PredisTest
phpunit --bootstrap vendor/autoload.php  tests/Adapter/MemoryTest
phpunit --bootstrap vendor/autoload.php  tests/Adapter/FileTest