diff --git a/.env.docker.example b/.env.docker.example index e0e8d9d..3662f9f 100644 --- a/.env.docker.example +++ b/.env.docker.example @@ -55,6 +55,8 @@ DB_MAX_CONNECTIONS=10 DB_IDLE_TIMEOUT=60 # Recent data will be stored in memory this amount of time: DB_CACHE_TTL="+5 minutes" +# Options: serialize, igbinary +DB_SERIALIZER=serialize # Enable to add cache info about users to database. Disable if you only read data from channels. DB_ENABLE_MIN_DATABASE=0 # Enable file metadata cache diff --git a/.env.example b/.env.example index c8bd3fd..cab1087 100644 --- a/.env.example +++ b/.env.example @@ -54,6 +54,8 @@ DB_MAX_CONNECTIONS=10 DB_IDLE_TIMEOUT=60 # Recent data will be stored in memory this amount of time: DB_CACHE_TTL="+5 minutes" +# Options: serialize, igbinary +DB_SERIALIZER=serialize # Enable to add cache info about users to database. Disable if you only read data from channels. DB_ENABLE_MIN_DATABASE=0 # Enable file metadata cache diff --git a/Dockerfile b/Dockerfile index 043ed94..2c778b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,8 @@ RUN true \ && docker-php-ext-install -j$(nproc) sockets bcmath mysqli pdo_mysql pcntl ffi intl gmp zip gd \ # Install additional extension && mkdir -p /usr/src/php/ext/ && cd /usr/src/php/ext/ \ - && pecl bundle ev-beta && pecl bundle eio-beta \ - && docker-php-ext-install -j$(nproc) ev eio \ + && pecl bundle ev-beta && pecl bundle eio-beta && pecl bundle igbinary \ + && docker-php-ext-install -j$(nproc) ev eio igbinary \ # Install PrimeModule for AuthKey generation speedup && git clone https://github.com/danog/PrimeModule-ext \ && cd PrimeModule-ext && make -j$(nproc) \ diff --git a/config.php b/config.php index 6b70050..5e3a45f 100644 --- a/config.php +++ b/config.php @@ -50,7 +50,7 @@ 'max_connections' => (int)getenv('DB_MAX_CONNECTIONS'), 'idle_timeout' => (int)getenv('DB_IDLE_TIMEOUT'), 'cache_ttl' => (string)getenv('DB_CACHE_TTL'), - 'serializer' => danog\MadelineProto\Settings\Database\SerializerType::from('serialize'), + 'serializer' => ((string)getenv('DB_SERIALIZER')) ?: 'serialize', ] ], 'files' => [ diff --git a/src/Client.php b/src/Client.php index 8b09594..bc6c2a3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -5,6 +5,7 @@ use danog\MadelineProto\API; use danog\MadelineProto\APIWrapper; use danog\MadelineProto\Settings; +use danog\MadelineProto\Settings\Database\SerializerType; use danog\MadelineProto\SettingsAbstract; use InvalidArgumentException; use Psr\Log\LogLevel; @@ -187,6 +188,9 @@ private static function getSettingsFromArray(string $session, array $settings, S $method = 'get' . ucfirst(str_replace('_', '', ucwords($key, '_'))); self::getSettingsFromArray($session, $value, $settingsObject->$method()); } else { + if ($key === 'serializer' && is_string($value)) { + $value = SerializerType::from($value); + } $method = 'set' . ucfirst(str_replace('_', '', ucwords($key, '_'))); $settingsObject->$method($value); }