Link Search Menu Expand Document


By default madelineProto keeps all data and caches in memory: chats, file references, username cache, etc.
This data can require up to 1Gb of ram and more on certain accounts.
MadelineProto can keep part of this data in a database, such as mysql, mariadb, postgres or redis (you can also add your own!).

On first start after switching type all data will be migrated from the previous backend to the new one. Database to memory migration/convertation is also supported.

Databases and tables will be created automatically.

You can also directly connect the event handler using the same async MySQL/Postgres/Redis ORM used by MadelineProto internally.

Related settings:

See the settings documentation for more info.

Mysql example (low memory usage):

$settings = (new \danog\MadelineProto\Settings\Database\Mysql)

$API = new \danog\MadelineProto\API('session.madeline', $settings);

Postgres example (low memory usage):

$settings = (new \danog\MadelineProto\Settings\Database\Postgres)

Redis example (medium memory usage, faster access):

$settings = (new \danog\MadelineProto\Settings\Database\Redis)

Memory example (medium-high memory usage, fastest access):

$settings = new \danog\MadelineProto\Settings\Database\Memory;

Next section