Skip to content

Commit 10ca9aa

Browse files
committed
async herd docs
1 parent 023e181 commit 10ca9aa

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

docs/source/async/advanced_configurations.rst

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

15-
as of now, we only have one async client, ``AsyncDefaultClient``, available in ``django_valkey.async_cache.client.default``.
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``.
1616
the default client can also be used with sentinels, as we'll discuss later.
1717

18+
Default client
19+
^^^^^^^^^^^^^^
20+
1821
the ``AsyncDefaultClient`` is configured by default by ``AsyncValkeyCache``, so if you have configured that as your backend you are all set, but if you want to be explicit or use the client with a different backend you can write it like this:
1922

2023
.. code-block:: python
@@ -33,6 +36,23 @@ the ``AsyncDefaultClient`` is configured by default by ``AsyncValkeyCache``, so
3336
3437
or you can replace the client with your own like that.
3538

39+
Herd client
40+
^^^^^^^^^^^
41+
42+
the herd client needs to be configured, but it's as simple as this:
43+
44+
.. code-block:: python
45+
46+
CACHES = {
47+
"default": {
48+
"BACKEND": "django_valkey.async_cache.cache.AsyncValkeyCache",
49+
"LOCATION": ["valkey://127.0.0.1:6379"],
50+
"OPTIONS": {
51+
"CLIENT_CLASS": "django_valkey.async_cache.client.AsyncHerdClient",
52+
}
53+
}
54+
}
55+
3656
Connection Factory
3757
##################
3858

@@ -51,6 +71,8 @@ the default connection factory is ``AsyncConnectionFactory``, so if you are usin
5171
}
5272
}
5373
74+
CACHE_HERD_TIMEOUT = 20 # if not set, it's default to 60
75+
5476
or set it as the global connection factory like this:
5577

5678
.. code-block:: python

docs/source/async/configuration.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Configure The Async Client
55
**Important**: the async client is not compatible with django's cache middlewares.
66
if you need the middlewares, consider using the sync client or implement a new middleware.
77

8-
as of now, we have one async client available, working on more tho.
8+
there are two async clients available, a normal client and a herd client.
9+
10+
Default client
11+
##############
912

1013
to setup the async client you can configure your settings file to look like this:
1114

@@ -14,7 +17,7 @@ to setup the async client you can configure your settings file to look like this
1417
CACHES = {
1518
"default": {
1619
"BACKEND": "django_valkey.async_cache.cache.AsyncValkeyCache",
17-
"LOCATION": "valkey://127.0.0.1:6379","
20+
"LOCATION": "valkey://127.0.0.1:6379",
1821
"OPTIONS": {...},
1922
},
2023
}
@@ -24,4 +27,21 @@ And that's it, the backend defaults to use AsyncDefaultClient as client interfac
2427

2528
you can, of course configure it to use any other class, or pass in extras args and kwargs, the same way that was discussed at :doc:`../configure/advanced_configurations`.
2629

30+
Herd client
31+
###########
32+
33+
to set up herd client configure your settings like this:
34+
35+
.. code-block:: python
36+
37+
CACHES = {
38+
"default": {
39+
"BACKEND": "django_valkey.async_cache.caches.AsyncValkeyCache",
40+
"LOCATION": "valkey://127.0.0.1:6379",
41+
"OPTIONS": {
42+
"CLIENT_CLASS": "django_valkey.async_cache.client.AsyncHerdClient",
43+
},
44+
},
45+
}
46+
2747
for a more specified guide look at :doc:`advanced_configurations`.

0 commit comments

Comments
 (0)