PHP code example of stepanrodionov / php-apcu-cache

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

    

stepanrodionov / php-apcu-cache example snippets


$cache = new SR\Cache\ApcuCacheStorage();

//  store variable with ttl
$success = $cache->set('key', $variable, 3600);

//  get variable
$variable = $cache->get('key');

//  'key' will be overwritten
$cache->set('key', $anotherVar, 3600);

//  deleting one cached variable and all of them
$cache->delete('key');
$cache->clear();

// dealing with multiple data
$cache->getMultiple([
    'key', 
    'key1',
]);
$cache->setMultiple([
    'key' => 'value',
    'key1' => 'value1',
]);
$cache->deleteMultiple([
    'key', 
    'key1',
]);

//  check if variable exists
$isVarCached = $cache->has('key');