Added Unittests for cache

fixed Lock & Cache bugs
This commit is contained in:
Philipp Holzer 2018-07-07 19:46:16 +02:00
parent 1dafaa69c5
commit 80a4e6263f
No known key found for this signature in database
GPG key ID: 58160D7D6AF942B6
18 changed files with 317 additions and 25 deletions

View file

@ -37,7 +37,7 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
{
$fields = [
'v' => serialize($value),
'expires' => DateTimeFormat::utc('now + ' . $ttl . ' seconds'),
'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds'),
'updated' => DateTimeFormat::utcNow()
];
@ -49,8 +49,12 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
return dba::delete('cache', ['k' => $key]);
}
public function clear()
public function clear($outdated = true)
{
return dba::delete('cache', ['`expires` < NOW()']);
if ($outdated) {
return dba::delete('cache', ['`expires` < NOW()']);
} else {
return dba::delete('cache', ['`k` IS NOT NULL ']);
}
}
}