Use 0 for unlimited expiry
This commit is contained in:
parent
05a045268f
commit
b4259a6bf3
@ -36,9 +36,9 @@ trait FilesystemTrait
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($time >= (int) $expiresAt = fgets($h)) {
|
if (($expiresAt = (int) fgets($h)) && $time >= $expiresAt) {
|
||||||
fclose($h);
|
fclose($h);
|
||||||
$pruned = isset($expiresAt[0]) && @unlink($file) && !file_exists($file) && $pruned;
|
$pruned = @unlink($file) && !file_exists($file) && $pruned;
|
||||||
} else {
|
} else {
|
||||||
fclose($h);
|
fclose($h);
|
||||||
}
|
}
|
||||||
@ -60,11 +60,9 @@ trait FilesystemTrait
|
|||||||
if (!file_exists($file) || !$h = @fopen($file, 'rb')) {
|
if (!file_exists($file) || !$h = @fopen($file, 'rb')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($now >= (int) $expiresAt = fgets($h)) {
|
if (($expiresAt = (int) fgets($h)) && $now >= $expiresAt) {
|
||||||
fclose($h);
|
fclose($h);
|
||||||
if (isset($expiresAt[0])) {
|
@unlink($file);
|
||||||
@unlink($file);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$i = rawurldecode(rtrim(fgets($h)));
|
$i = rawurldecode(rtrim(fgets($h)));
|
||||||
$value = stream_get_contents($h);
|
$value = stream_get_contents($h);
|
||||||
@ -94,7 +92,7 @@ trait FilesystemTrait
|
|||||||
protected function doSave(array $values, $lifetime)
|
protected function doSave(array $values, $lifetime)
|
||||||
{
|
{
|
||||||
$ok = true;
|
$ok = true;
|
||||||
$expiresAt = time() + ($lifetime ?: 31557600); // 31557600s = 1 year
|
$expiresAt = $lifetime ? (time() + $lifetime) : 0;
|
||||||
|
|
||||||
foreach ($values as $id => $value) {
|
foreach ($values as $id => $value) {
|
||||||
$ok = $this->write($this->getFile($id, true), $expiresAt."\n".rawurlencode($id)."\n".serialize($value), $expiresAt) && $ok;
|
$ok = $this->write($this->getFile($id, true), $expiresAt."\n".rawurlencode($id)."\n".serialize($value), $expiresAt) && $ok;
|
||||||
|
Reference in New Issue
Block a user