mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Add docs for storages.
This commit is contained in:
parent
a59c5af5d0
commit
53292dad15
4 changed files with 30 additions and 7 deletions
|
|
@ -41,7 +41,6 @@ class RedisStorage(BaseStorage):
|
|||
Get Redis connection
|
||||
|
||||
This property is awaitable.
|
||||
:return:
|
||||
"""
|
||||
if self._redis is None:
|
||||
self._redis = await aioredis.create_connection((self._host, self._port),
|
||||
|
|
@ -50,7 +49,9 @@ class RedisStorage(BaseStorage):
|
|||
**self._kwargs)
|
||||
return self._redis
|
||||
|
||||
async def get_record(self, *, chat: typing.Union[str, int, None] = None, user: typing.Union[str, int, None] = None):
|
||||
async def get_record(self, *,
|
||||
chat: typing.Union[str, int, None] = None,
|
||||
user: typing.Union[str, int, None] = None) -> typing.Dict:
|
||||
"""
|
||||
Get record from storage
|
||||
|
||||
|
|
@ -61,8 +62,8 @@ class RedisStorage(BaseStorage):
|
|||
chat, user = self.check_address(chat=chat, user=user)
|
||||
addr = f"{chat}:{user}"
|
||||
|
||||
redis = await self.redis
|
||||
data = await redis.execute('GET', addr)
|
||||
conn = await self.redis
|
||||
data = await conn.execute('GET', addr)
|
||||
if data is None:
|
||||
return {'state': None, 'data': {}}
|
||||
return json.loads(data)
|
||||
|
|
|
|||
5
docs/source/contrib/contrib.rst
Normal file
5
docs/source/contrib/contrib.rst
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Contrib
|
||||
=======
|
||||
|
||||
.. toctree::
|
||||
storages
|
||||
18
docs/source/contrib/storages.rst
Normal file
18
docs/source/contrib/storages.rst
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Storages for FSM
|
||||
================
|
||||
|
||||
You can create you own storage by extending :class:`aiogram.dispatcher.storage.BaseStorage` or use default storages:
|
||||
|
||||
Simple in-memory storage
|
||||
------------------------
|
||||
|
||||
.. automodule:: aiogram.contrib.fsm_storage.memory
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Redis storage
|
||||
-------------
|
||||
|
||||
.. automodule:: aiogram.contrib.fsm_storage.redis
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
Features
|
||||
========
|
||||
|
||||
Markdown
|
||||
--------
|
||||
|
||||
.. toctree::
|
||||
contrib/contrib
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue