| sidebar_position |
|---|
1 |
PSR-16 is a standard for cache in PHP with less verbosity than PSR-6.
You can just instantiate the cache engine and use it as you can see below.
<?php
$cacheEngine = new \ByJG\Cache\Psr16\FileSystemCacheEngine();
$result = $cacheEngine->get($key);
if (empty($result)) {
// Do the operations that will be cached
// ....
// And set variable result
$result = "...";
// Set the cache with 60 seconds TTL:
$cacheEngine->set($key, $result, 60);
}
return $result;<?php
$cacheEngine = new \ByJG\Cache\Psr16\FileSystemCacheEngine();
if ($cacheEngine->has($key)) {
// ...
}<?php
$cacheEngine = new \ByJG\Cache\Psr16\FileSystemCacheEngine();
$cacheEngine->delete($key);<?php
$cacheEngine = new \ByJG\Cache\Psr16\FileSystemCacheEngine();
$cacheEngine->clear();