mirror of
https://github.com/friendica/friendica
synced 2025-04-26 09:10:15 +00:00
Adding force to update routine
- Introduced Cache::NEVER Lock (never expiring lock) - Force flag for dbstructure update - Moving the business logic to central place in Update class
This commit is contained in:
parent
f2ec963b95
commit
270e817954
9 changed files with 141 additions and 104 deletions
|
@ -40,7 +40,7 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
|
|||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$cache = DBA::selectFirst('cache', ['v'], ['`k` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
|
||||
$cache = DBA::selectFirst('cache', ['v'], ['`k` = ? AND (`expires` >= ? OR `expires` = -1)', $key, DateTimeFormat::utcNow()]);
|
||||
|
||||
if (DBA::isResult($cache)) {
|
||||
$cached = $cache['v'];
|
||||
|
@ -62,11 +62,19 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
|
|||
*/
|
||||
public function set($key, $value, $ttl = Cache::FIVE_MINUTES)
|
||||
{
|
||||
$fields = [
|
||||
'v' => serialize($value),
|
||||
'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds'),
|
||||
'updated' => DateTimeFormat::utcNow()
|
||||
];
|
||||
if ($ttl > 0) {
|
||||
$fields = [
|
||||
'v' => serialize($value),
|
||||
'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds'),
|
||||
'updated' => DateTimeFormat::utcNow()
|
||||
];
|
||||
} else {
|
||||
$fields = [
|
||||
'v' => serialize($value),
|
||||
'expires' => -1,
|
||||
'updated' => DateTimeFormat::utcNow()
|
||||
];
|
||||
}
|
||||
|
||||
return DBA::update('cache', $fields, ['k' => $key], true);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ interface ICacheDriver
|
|||
*
|
||||
* @param string $key The cache key
|
||||
* @param mixed $value The value to store
|
||||
* @param integer $ttl The cache lifespan, must be one of the Cache constants
|
||||
* @param integer $ttl The cache lifespan, must be one of the Cache constants
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,7 @@ interface IMemoryCacheDriver extends ICacheDriver
|
|||
* @param string $key The cache key
|
||||
* @param mixed $oldValue The old value we know from the cache
|
||||
* @param mixed $newValue The new value we want to set
|
||||
* @param int $ttl The cache lifespan, must be one of the Cache constants
|
||||
* @param int $ttl The cache lifespan, must be one of the Cache constants
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue