You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
715 B

<?php
namespace Kanti;
class CacheOneFile {
protected $fileName = "";
protected $holdTime = 43200; //12h
public function __construct($fileName, $holdTime = 43200) {
$this->fileName = $fileName;
$this->holdTime = $holdTime;
}
public function is() {
if (!file_exists($this->fileName))
return false;
if (filemtime($this->fileName) < ( time() - $this->holdTime )) {
unlink($this->fileName);
return false;
}
return true;
}
public function get() {
return file_get_contents($this->fileName);
}
public function set($content) {
file_put_contents($this->fileName, $content);
}
}