1. Go to this page and download the library: Download pluggit/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/ */
pluggit / cache example snippets
/** @var \Cmp\Cache\Cache $cache */
$cache = (new CacheBuilder)
->withLogging($psrLogger)
->withoutExceptions()
->withArrayCache()
->withRedisCacheFromParams($host, $port, $dbNumber)
->build();
// Set an item
$cache->set('foo', 'bar');
// Demand an item, throws an exception if not present
$bar = $cache->demand('foo');
// Get an item, if not present in any cache it will return the given default
$default = $cache->get('not found', 'default');
// Delete an item
$cache->delete('foo');
// Empty the cache
$cache->flush();
//Create a tagged cache
$taggedCache = $cache->tag('myTag');
//Set a tagged item
$taggedCache->set('key','value');
//Remove all tagged items
$taggedCache->flush();
// Store one photo in the cache
$cache->set('photo.1', $photoOne);
// Store a set of photos and tag them
$cache->tag('photos')->set('photo.1', $taggedPhotoOne);
$cache->tag('photos')->set('photo.2', $taggedPhotoTwo);
// The photos are into different buckets
$cache->has('photo.1'); // true
$cache->has('photo.2') // false
$cache->tag('photos')->has('photo.1'); // true
$cache->tag('photos')->has('photo.2') // true
// You can flush all items with the same tag at once
$cache->tag('photos')->flush();
$cache->has('photo.1'); // true
$cache->tag('photos')->has('photo.1'); // false