File: /usr/local/lsws/pg88zc.com/html/wp-content/plugins/mlink-plugin/includes/helpers/cache.php
<?php
namespace GwdMlinkPlugin\Helpers;
class Cache
{
public function get($key)
{
$filePath = $this->getKeyPath($key);
if (file_exists($filePath)) {
return file_get_contents($filePath);
}
return false;
}
public function set($key, $data)
{
$filePath = $this->getKeyPath($key);
if (!file_exists(dirname($filePath))) {
mkdir(dirname($filePath), 0755, true);
}
return file_put_contents($filePath, json_encode($data));
}
private function getKeyPath($key)
{
$cachePath = GWD_MLINK_DIR . '/includes/cache/';
return $cachePath . $key . '.json';
}
public function delete($key)
{
$filePath = $this->getKeyPath($key);
return unlink($filePath);
}
}