Fix wrong session expire set for custom duration
This commit is contained in:
parent
f94134f556
commit
ef0701a97a
4 changed files with 11 additions and 50 deletions
|
@ -12,14 +12,14 @@ use Friendica\Core\Config;
|
||||||
*/
|
*/
|
||||||
class Cache extends \Friendica\BaseObject
|
class Cache extends \Friendica\BaseObject
|
||||||
{
|
{
|
||||||
const MONTH = 0;
|
const MONTH = 2592000;
|
||||||
const WEEK = 1;
|
const WEEK = 604800;
|
||||||
const DAY = 2;
|
const DAY = 86400;
|
||||||
const HOUR = 3;
|
const HOUR = 3600;
|
||||||
const HALF_HOUR = 4;
|
const HALF_HOUR = 1800;
|
||||||
const QUARTER_HOUR = 5;
|
const QUARTER_HOUR = 900;
|
||||||
const FIVE_MINUTES = 6;
|
const FIVE_MINUTES = 300;
|
||||||
const MINUTE = 7;
|
const MINUTE = 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Cache\ICacheDriver
|
* @var Cache\ICacheDriver
|
||||||
|
@ -45,45 +45,6 @@ class Cache extends \Friendica\BaseObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the duration for a given cache level
|
|
||||||
*
|
|
||||||
* @param integer $level Cache level
|
|
||||||
*
|
|
||||||
* @return integer The cache duration in seconds
|
|
||||||
*/
|
|
||||||
public static function duration($level)
|
|
||||||
{
|
|
||||||
switch ($level) {
|
|
||||||
case self::MONTH:
|
|
||||||
$seconds = 2592000;
|
|
||||||
break;
|
|
||||||
case self::WEEK:
|
|
||||||
$seconds = 604800;
|
|
||||||
break;
|
|
||||||
case self::DAY:
|
|
||||||
$seconds = 86400;
|
|
||||||
break;
|
|
||||||
case self::HOUR:
|
|
||||||
$seconds = 3600;
|
|
||||||
break;
|
|
||||||
case self::HALF_HOUR:
|
|
||||||
$seconds = 1800;
|
|
||||||
break;
|
|
||||||
case self::QUARTER_HOUR:
|
|
||||||
$seconds = 900;
|
|
||||||
break;
|
|
||||||
case self::FIVE_MINUTES:
|
|
||||||
$seconds = 300;
|
|
||||||
break;
|
|
||||||
case self::MINUTE:
|
|
||||||
default:
|
|
||||||
$seconds = 60;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $seconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current cache driver
|
* Returns the current cache driver
|
||||||
*
|
*
|
||||||
|
|
|
@ -37,7 +37,7 @@ class DatabaseCacheDriver implements ICacheDriver
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'v' => serialize($value),
|
'v' => serialize($value),
|
||||||
'expires' => DateTimeFormat::utc('now + ' . Cache::duration($duration) . ' seconds'),
|
'expires' => DateTimeFormat::utc('now + ' . $duration . ' seconds'),
|
||||||
'updated' => DateTimeFormat::utcNow()
|
'updated' => DateTimeFormat::utcNow()
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class MemcacheCacheDriver extends BaseObject implements ICacheDriver
|
||||||
self::getApp()->get_hostname() . ":" . $key,
|
self::getApp()->get_hostname() . ":" . $key,
|
||||||
serialize($value),
|
serialize($value),
|
||||||
MEMCACHE_COMPRESSED,
|
MEMCACHE_COMPRESSED,
|
||||||
Cache::duration($duration)
|
time() + $duration
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class MemcachedCacheDriver extends BaseObject implements ICacheDriver
|
||||||
return $this->memcached->set(
|
return $this->memcached->set(
|
||||||
self::getApp()->get_hostname() . ":" . $key,
|
self::getApp()->get_hostname() . ":" . $key,
|
||||||
$value,
|
$value,
|
||||||
Cache::duration($duration)
|
time() + $duration
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue