for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Kevinrob\GuzzleCache\Storage;
use Kevinrob\GuzzleCache\CacheEntry;
class WordPressObjectCacheStorage implements CacheStorageInterface
{
/**
* @var string
*/
private $group;
* @param string $group
public function __construct($group = 'guzzle')
$this->group = $group;
}
* @param string $key
*
* @return CacheEntry|null the data or false
public function fetch($key)
try {
$cache = unserialize(wp_cache_get($key, $this->group));
if ($cache instanceof CacheEntry) {
return $cache;
} catch (\Exception $ignored) {
// Don't fail if we can't load it
return null;
* @param CacheEntry $data
* @return bool
public function save($key, CacheEntry $data)
return wp_cache_set($key, serialize($data), $this->group, $data->getTTL());
// Don't fail if we can't save it
return false;
public function delete($key)
return wp_cache_delete($key, $this->group);
// Don't fail if we can't delete it