PHP code example of genkgo / cache
1. Go to this page and download the library: Download genkgo/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/ */
genkgo / cache example snippets
namespace My\Namespace;
use Genkgo\Cache\CacheAdapterInterface;
class ArrayAdapter implements CacheAdapterInterface
{
private $data = [];
public function set($key, $value)
{
$this->data[$key] = $value;
}
public function get($key)
{
if ($this->exists($key)) {
return $this->data[$key];
}
}
public function delete($key)
{
if ($this->exists($key)) {
unset($this->data[$key]);
}
}
private function exists($key)
{
return isset($this->data[$key]) || array_key_exists($key, $this->data);
}
}