| Server IP : 82.208.35.60 / Your IP : 216.73.216.168 Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31 System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64 User : studiokobylisy_cz ( 1008) PHP Version : 7.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/d2m/sofident_cz/wp-content/plugins/shortpixel-image-optimiser/class/Model/ |
Upload File : |
<?php
namespace ShortPixel\Model;
use ShortPixel\ShortpixelLogger\ShortPixelLogger as Log;
/* Model for storing cached data
*
* Use this in conjunction with cache controller, don't call it stand-alone.
*/
class CacheModel
{
protected $name;
protected $value;
protected $expires = HOUR_IN_SECONDS; // This is the expires, when saved without SetExpires! This value is not a representation of any expire time when loading something cache!
protected $exists = false;
public function __construct($name)
{
$this->name = $name;
$this->load();
}
/** Set the expiration of this item. In seconds
* @param $time Expiration in Seconds
*/
public function setExpires($time)
{
$this->expires = $time;
}
public function setValue($value)
{
$this->value = $value;
}
public function exists()
{
return $this->exists;
}
public function getValue()
{
return $this->value;
}
public function getName()
{
return $this->name;
}
public function save()
{
$this->exists = set_transient($this->name, $this->value, $this->expires);
}
public function delete()
{
delete_transient($this->name);
$this->exists = false;
}
protected function load()
{
$item = get_transient($this->name);
if ($item !== false)
{
$this->value = $item;
$this->exists = true;
}
}
}