Skip to content

Commit 6e8c297

Browse files
committed
added async sentinel documentations
1 parent 9ef2424 commit 6e8c297

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

docs/source/async/advanced_configurations.rst

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ if you need those middlewares, consider using a sync client or implement a new m
1212
Clients
1313
#######
1414

15-
as of now, we have two async client, ``AsyncDefaultClient``, available in ``django_valkey.async_cache.client.default``, and ``AsyncHerdClient`` available in ``django_valkey.async_cache.client.herd``.
15+
We have three async client, ``AsyncDefaultClient``, available in ``django_valkey.async_cache.client.default``, ``AsyncHerdClient`` available in ``django_valkey.async_cache.client.herd`` and ``AsyncSentinelClient`` at ``django_valkey.async_cache.client.sentinel``.
1616
the default client can also be used with sentinels, as we'll discuss later.
1717

18+
note that all clients are imported and available at ``django_valkey.async_cache.client``
19+
1820
Default client
1921
^^^^^^^^^^^^^^
2022

@@ -36,6 +38,38 @@ the ``AsyncDefaultClient`` is configured by default by ``AsyncValkeyCache``, so
3638
3739
or you can replace the client with your own like that.
3840

41+
Sentinel Client
42+
^^^^^^^^^^^^^^^
43+
44+
to support sentinels, django_valkey comes with a client and a connection factory, technically you don't need the connection factory, but it provides you with some nice features.
45+
a dedicated page on sentinel client has been written in :doc:`../configure/sentinel_configurations`, tho that is for the sync version, the principle is the same.
46+
47+
the connection factory is at ``django_valkey.async_cache.pool.AsyncSentinelConnectionFactory``.
48+
49+
to configure the async sentinel client you can write your settings like this:
50+
51+
.. code-block:: python
52+
53+
SENTINELS = [
54+
("127.0.0.1", 26379), # a list of (host name, port) tuples.
55+
]
56+
57+
CACHES = {
58+
"default": {
59+
"BACKEND": "django_valkey.async_cache.cache.AsyncValkeyCache",
60+
"LOCATION": "valkey://service_name/db",
61+
"OPTIONS": {
62+
"CLIENT_CLASS": "django_valkey.client.SentinelClient",
63+
"SENTINELS": SENTINELS,
64+
65+
# optional
66+
"SENTINEL_KWARGS": {}
67+
}
68+
}
69+
}
70+
71+
*note*: the sentinel client uses the sentinel connection factory by default, you can change it by setting ``DJANGO_VALKEY_CONNECTION_FACTORY`` in your django settings or ``CONNECTION_FACTORY`` in your ``CACHES`` OPTIONS.
72+
3973
Herd client
4074
^^^^^^^^^^^
4175

0 commit comments

Comments
 (0)