Skip to content

Commit 5e532eb

Browse files
authored
Updated documentation for redis module (#761)
1 parent f25b750 commit 5e532eb

File tree

10 files changed

+17
-27
lines changed

10 files changed

+17
-27
lines changed

.mypy.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ disallow_any_unimported = False
2727
[mypy-aiopg.*]
2828
ignore_missing_imports = True
2929

30-
[mypy-aioredis.*]
31-
ignore_missing_imports = True
32-
3330
[mypy-aiomcache.*]
3431
ignore_missing_imports = True
3532

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ setup:
77
flake fmt:
88
python -m pre_commit run --all-files
99

10-
1110
test:
1211
py.test ./tests/
1312

README.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ Available session storages are:
7979

8080
* ``aiohttp_session.redis_storage.RedisStorage(redis_pool)`` -- stores
8181
JSON encoded data in *redis*, keeping only the redis key (a random UUID) in
82-
the cookie. ``redis_pool`` is a ``aioredis`` pool object, created by
83-
``await aioredis.create_redis_pool(...)`` call.
84-
85-
Requires ``aioredis`` library (only versions ``1.0+`` are supported)::
82+
the cookie. ``redis_pool`` is a ``redis`` object, created by
83+
``await aioredis.from_url(...)`` call.
8684

8785
$ pip install aiohttp_session[aioredis]
8886

aiohttp_session/redis_storage.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from . import AbstractStorage, Session
88

99
try:
10-
from redis import asyncio as aioredis
11-
from redis import VERSION as REDIS_VERSION
10+
from redis import VERSION as REDIS_VERSION, asyncio as aioredis
1211
except ImportError: # pragma: no cover
1312
aioredis = None # type: ignore[assignment]
1413

demo/redis_storage.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import time
22
from typing import AsyncIterator
33

4-
import aioredis
54
from aiohttp import web
5+
from redis import asyncio as aioredis
66

77
from aiohttp_session import get_session, setup
88
from aiohttp_session.redis_storage import RedisStorage
@@ -18,10 +18,7 @@ async def handler(request: web.Request) -> web.Response:
1818

1919
async def redis_pool(app: web.Application) -> AsyncIterator[None]:
2020
redis_address = "redis://127.0.0.1:6379"
21-
async with aioredis.from_url(
22-
redis_address,
23-
timeout=1,
24-
) as redis:
21+
async with aioredis.from_url(redis_address) as redis:
2522
storage = RedisStorage(redis)
2623
setup(app, storage)
2724
yield

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
intersphinx_mapping = {
344344
"https://docs.python.org/3": None,
345345
"https://aiohttp.readthedocs.io/en/stable": None,
346-
"https://aioredis.readthedocs.io/en/latest": None,
346+
"https://redis.readthedocs.io/en/latest": None,
347347
# 'https://github.com/aio-libs/aiomcache': None,
348348
"http://cryptography.io/en/latest": None,
349349
"https://pynacl.readthedocs.io/en/latest": None,

docs/glossary.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
aioredis
1212

13-
:term:`asyncio` compatible Redis client library
13+
:term:`asyncio` compatible module in the :term:`redis` library.
1414

15-
https://aioredis.readthedocs.io/
15+
https://redis-py.readthedocs.io/en/stable/examples/asyncio_examples.html
1616

1717
aiomcache
1818

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Available session storages are:
7979
``e33b57c7ec6e425eb626610f811ab6ae`` (a random UUID) they key inside
8080
redis will be ``AIOHTTP_SESSION_e33b57c7ec6e425eb626610f811ab6ae``.
8181

82-
Requires :term:`aioredis` library:
82+
Requires :term:`redis` library:
8383

8484
.. code-block:: bash
8585
@@ -121,7 +121,7 @@ Dependencies
121121

122122
- :term:`cryptography` for
123123
:class:`~aiohttp_session.cookie_storage.EncryptedCookieStorage`
124-
- :term:`aioredis` for
124+
- :term:`redis` for
125125
:class:`~aiohttp_session.redis_storage.RedisStorage`
126126

127127

docs/reference.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,11 @@ Redis Storage
378378
The storage that stores session data in Redis database and
379379
keeps only Redis keys (UUIDs actually) in HTTP cookies.
380380

381-
It operates with Redis database via :class:`aioredis.RedisPool`.
381+
It operates with Redis database via :class:`redis.asyncio.Redis`.
382382

383383
To use the storage you need setup it first::
384384

385-
redis = await aioredis.create_pool(('localhost', 6379))
385+
redis = await aioredis.from_url("redis://127.0.0.1:6379")
386386
storage = aiohttp_session.redis_storage.RedisStorage(redis)
387387
aiohttp_session.setup(app, storage)
388388

@@ -398,18 +398,18 @@ To use the storage you need setup it first::
398398

399399
The class is inherited from :class:`~aiohttp_session.AbstractStorage`.
400400

401-
*redis_pool* is a :class:`~aioredis.RedisPool` which should be
402-
created by :func:`~aioredis.create_pool` call, e.g.::
401+
*redis_pool* is a :class:`~redis.asyncio.Redis` which should be
402+
created by :func:`~redis.asyncio.from_url` call, e.g.::
403403

404-
redis = await aioredis.create_pool(('localhost', 6379))
404+
redis = await aioredis.from_url("redis://localhost:6379")
405405
storage = aiohttp_session.redis_storage.RedisStorage(redis)
406406

407407
Other parameters are the same as for
408408
:class:`~aiohttp_session.AbstractStorage` constructor.
409409

410410

411411
Memcached Storage
412-
----------------
412+
-----------------
413413

414414
The storage that stores session data in Memcached and
415415
keeps only keys (UUIDs actually) in HTTP cookies.

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-e .
22
aiohttp==3.8.3
33
aiomcache==0.7.0
4-
redis==4.3.4
54
attrs==22.1.0
65
chardet==5.0.0
76
cryptography==38.0.1
@@ -21,6 +20,7 @@ pytest-aiohttp==1.0.4
2120
pytest-cov==4.0.0
2221
pytest-mock==3.10.0
2322
pytest-sugar==0.9.5
23+
redis==4.3.4
2424
sphinx==4.3.2
2525
types-redis==4.3.21.3
2626
typing-extensions==4.4.0

0 commit comments

Comments
 (0)