PHP code example of kuick / cache

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

    

kuick / cache example snippets




use Kuick\Cache\FilesystemCache;

$fileCache = new FilesystemCache('/tmp/cache');
$fileCache->set('foo', 'bar');
echo $fileCache->get('foo'); // bar



use Kuick\Cache\CacheFactory;

$cacheFactory = new CacheFactory();

$dbCache    = $cacheFactory('pdo-mysql://127.0.0.1:3306/mydb'); // DbalCache instance
$apcuCache  = $cacheFactory('apcu://');                         // ApcuCache instance
$fileCache  = $cacheFactory('file:///tmp/cache');               // FilesystemCache instance
$redisCache = $cacheFactory('redis://redis-server.com:6379/2'); // RedisCache instance



use Kuick\Cache\InMemoryCache;

$cache = new InMemoryCache();
$cache->set('foo', 'bar', 300);     // set "foo" to "bar", with 5 minutes ttl
$cache->get('foo');                 // "bar"
$cache->get('inexistent, 'default') // "default" (using the default value as the key does not exist)
$cache->has('foo');                 // true
$cache->delete('foo');              // remove "foo"

// set "foo" to "bar", and "bar" to "baz"
$cache->setMultiple([
    'foo' => 'bar',
    'bar' => 'baz',
]);

// ['foo' => 'bar', 'bar' => 'baz']
$cache->getMultiple([
    'foo',
    'bar',
]);

// removes "foo" and "bar"
$cache->deleteMultiple([
    'foo',
    'bar',
]);

// removes all the keys
$cache->clear();