1. Go to this page and download the library: Download webclient/cache-contract 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/ */
webclient / cache-contract example snippets
use Webclient\Cache\Contract\CacheInterface;
class SplitCache implements CacheInterface
{
private CacheInterface $settingsCache;
private CacheInterface $responsesCache;
public function __construct(CacheInterface $settingsCache, CacheInterface $responsesCache)
{
$this->settingsCache = $settingsCache;
$this->responsesCache = $responsesCache;
}
public function get(string $key) : ?string
{
$this->getStorage($key)->get($key);
}
public function set(string $key,string $data,?int $ttl = null) : void
{
$this->getStorage($key)->get($key, $data, $ttl);
}
private function getStorage(string $key): CacheInterface
{
if (strpos($key, 'http.settings.') === 0) {
return $this->settingsCache;
}
if (strpos($key, 'http.response.') === 0) {
return $this->responsesCache;
}
throw new InvalidArgumentException('can not define storage');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.