Bugfix for cache TTL

This commit is contained in:
Daniil Gentili 2020-10-07 16:54:11 +02:00
parent 6ce4de6091
commit 0ca0707529
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 9 additions and 6 deletions

View File

@ -33,6 +33,10 @@ abstract class EventHandler extends InternalDoc
* Whether the event handler was started.
*/
private bool $startedInternal = false;
/**
* API instance.
*/
protected MTProto $API;
/**
* Internal constructor.
*

View File

@ -26,9 +26,6 @@ abstract class DatabaseAbstract extends SettingsDatabaseAbstract
'cache_ttl'
]) as $object => $array) {
if (isset($settings[$array])) {
if ($array === 'cache_ttl' && \is_string($settings[$array])) {
$settings[$array] = \strtotime($settings[$array]);
}
$this->{$object}($settings[$array]);
}
}
@ -60,13 +57,15 @@ abstract class DatabaseAbstract extends SettingsDatabaseAbstract
/**
* Set for how long to keep records in memory after last read, for cached backends.
*
* @param int $cacheTtl For how long to keep records in memory after last read, for cached backends.
* The cache TTL identifier can be a string like '+5 minutes'.
*
* @param int|string $cacheTtl For how long to keep records in memory after last read, for cached backends.
*
* @return self
*/
public function setCacheTtl(int $cacheTtl): self
public function setCacheTtl($cacheTtl): self
{
$this->cacheTtl = $cacheTtl;
$this->cacheTtl = \is_int($cacheTtl) ? $cacheTtl : \strtotime($cacheTtl) - \time();
return $this;
}