Add configs to db properties

This commit is contained in:
Daniil Gentili 2020-09-25 22:17:05 +02:00
parent afaf80d549
commit 63c52fef50
3 changed files with 12 additions and 6 deletions

View File

@ -27,10 +27,12 @@ class DbPropertiesFactory
*/ */
public static function get(DatabaseAbstract $dbSettings, string $namePrefix, string $propertyType, string $name, $value = null): Promise public static function get(DatabaseAbstract $dbSettings, string $namePrefix, string $propertyType, string $name, $value = null): Promise
{ {
$config = $propertyType['config'] ?? [];
$propertyType = \is_array($propertyType) ? $propertyType['type'] : $propertyType;
$propertyType = \strtolower($propertyType); $propertyType = \strtolower($propertyType);
$class = $propertyType === 'arraynullcache' && !$dbSettings instanceof Memory $class = $config['enableCache'] ?? true && !$dbSettings instanceof Memory
? __NAMESPACE__.'\\NullCache' ? __NAMESPACE__
: __NAMESPACE__ ; : __NAMESPACE__.'\\NullCache';
switch (true) { switch (true) {
case $dbSettings instanceof Memory: case $dbSettings instanceof Memory:
@ -52,7 +54,6 @@ class DbPropertiesFactory
/** @var DbType $class */ /** @var DbType $class */
switch (\strtolower($propertyType)) { switch (\strtolower($propertyType)) {
case 'arraynullcache':
case 'array': case 'array':
$class .= 'Array'; $class .= 'Array';
break; break;

View File

@ -122,7 +122,9 @@ abstract class ClientAbstract
{ {
$this->run = false; $this->run = false;
yield $this->server->disconnect(); yield $this->server->disconnect();
foreach ($this->wrappers as $w) { yield from $w->disconnect(); } foreach ($this->wrappers as $w) {
yield from $w->disconnect();
}
} }
/** /**
* Call function. * Call function.

View File

@ -487,7 +487,10 @@ class MTProto extends AsyncConstruct implements TLCallback
'full_chats' => 'array', 'full_chats' => 'array',
'channel_participants' => 'array', 'channel_participants' => 'array',
'usernames' => 'array', 'usernames' => 'array',
'session' => 'arrayNullCache' 'session' => [
'type' => 'array',
'config' => ['enableCache' => false]
]
]; ];
/** /**