PHP code example of joefallon / phpcache

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

    

joefallon / phpcache example snippets


store($key, $value, array $tags = null, $expiresInSeconds = null);
retrieve($key);
exists($key);
remove($key);
removeByTag($tag);
removeAll();

use JoeFallon\Cache\ApcCache;
use JoeFallon\Cache\TaggedCache;

$cache = new TaggedCache(new ApcCache());   // use default namespace and expires

$key1   = 'key1';
$value1 = 'value1';

$cache->store($key1, $value1);

$key1Exists = $cache->exists($key1);
$value = null;

if($key1Exists)
{
    $value = $cache->retrieve($key1);
}
else
{
    $value = expensiveMethod();
}

use JoeFallon\Cache\ApcCache;
use JoeFallon\Cache\TaggedCache;

$cache = new TaggedCache(new ApcCache());   // use default namespace and expires

$key1   = 'key1';
$value1 = 'value1';

$cache->store($key1, $value1, array('tag1', 'tag2'));
$cache->removeByTag('tag2');  // the cache entry for 'key1' is deleted