Skip to content

Commit

Permalink
async herd docs
Browse files Browse the repository at this point in the history
  • Loading branch information
amirreza8002 committed Oct 9, 2024
1 parent 023e181 commit 10ca9aa
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
24 changes: 23 additions & 1 deletion docs/source/async/advanced_configurations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ if you need those middlewares, consider using a sync client or implement a new m
Clients
#######

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

Default client
^^^^^^^^^^^^^^

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:

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

Herd client
^^^^^^^^^^^

the herd client needs to be configured, but it's as simple as this:

.. code-block:: python
CACHES = {
"default": {
"BACKEND": "django_valkey.async_cache.cache.AsyncValkeyCache",
"LOCATION": ["valkey://127.0.0.1:6379"],
"OPTIONS": {
"CLIENT_CLASS": "django_valkey.async_cache.client.AsyncHerdClient",
}
}
}
Connection Factory
##################

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

.. code-block:: python
Expand Down
24 changes: 22 additions & 2 deletions docs/source/async/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ Configure The Async Client
**Important**: the async client is not compatible with django's cache middlewares.
if you need the middlewares, consider using the sync client or implement a new middleware.

as of now, we have one async client available, working on more tho.
there are two async clients available, a normal client and a herd client.

Default client
##############

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

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

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`.

Herd client
###########

to set up herd client configure your settings like this:

.. code-block:: python
CACHES = {
"default": {
"BACKEND": "django_valkey.async_cache.caches.AsyncValkeyCache",
"LOCATION": "valkey://127.0.0.1:6379",
"OPTIONS": {
"CLIENT_CLASS": "django_valkey.async_cache.client.AsyncHerdClient",
},
},
}
for a more specified guide look at :doc:`advanced_configurations`.

0 comments on commit 10ca9aa

Please sign in to comment.