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
{
$config = $propertyType['config'] ?? [];
$propertyType = \is_array($propertyType) ? $propertyType['type'] : $propertyType;
$propertyType = \strtolower($propertyType);
$class = $propertyType === 'arraynullcache' && !$dbSettings instanceof Memory
? __NAMESPACE__.'\\NullCache'
: __NAMESPACE__ ;
$class = $config['enableCache'] ?? true && !$dbSettings instanceof Memory
? __NAMESPACE__
: __NAMESPACE__.'\\NullCache';
switch (true) {
case $dbSettings instanceof Memory:
@ -52,7 +54,6 @@ class DbPropertiesFactory
/** @var DbType $class */
switch (\strtolower($propertyType)) {
case 'arraynullcache':
case 'array':
$class .= 'Array';
break;

View File

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

View File

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