Skip to content

Commit 9f2d64e

Browse files
committed
added mset, mget
1 parent 4381be5 commit 9f2d64e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

docs/source/commands/valkey_native_commands.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,31 @@ behaves in the same way as django backend contract specifies:
3030
cache.set("key", "value", timeout=None)
3131
3232
33+
Get and Set in bulk
34+
*******************
35+
36+
django-valkey has two different kind of method for bulk get/set: atomic and non-atomic.
37+
38+
atomic operations are done with ``mget()`` and ``mset()``
39+
40+
.. code-block:: pycon
41+
42+
>>> from django.core.cache import cache
43+
>>> cache.mset({"a": 1, "b": 2})
44+
>>> cache.mget(["a", "b"])
45+
{"a": 1, "b": 2}
46+
47+
the non atomic operations are done with ``get_many()`` and ``set_many()``doen
48+
49+
.. code-block:: pycon
50+
51+
>>> from django.core.cache import cache
52+
>>> cache.set_many({"a": 1, "b": 2})
53+
>>> cache.get_many(["a", "b"])
54+
{"a": 1, "b": 2}
55+
56+
**Note**: django-redis users should note that in django redis ``get_many()`` is an atomic operation, but ``set_many()`` is non-atomic.
57+
3358
Scan and Delete in bulk
3459
***********************
3560

docs/source/migration.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ you can easily fix this by running this commands:
3434
where settings.py is the file you have your configs in, change the file name if you are using a different name.
3535

3636

37+
Different commands
38+
##################
39+
40+
in django-redis, ``get_many()`` is an atomic operation, but ``set_many()`` is non-atomic.
41+
42+
in django-valkey ``mget()`` and ``mset()`` are atomic, and ``get_many()`` and ``set_many()`` are non-atomic.
43+
44+
3745
More options
3846
############
3947

0 commit comments

Comments
 (0)