Skip to content

Commit 0f9eb13

Browse files
padraic-shaferDreamsorcerer
authored andcommitted
Clarify requirement of keys for a multi_cached function (#645)
1 parent 91098a2 commit 0f9eb13

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

aiocache/decorators.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ def _get_args_dict(func, args, kwargs):
235235
class multi_cached:
236236
"""
237237
Only supports functions that return dict-like structures. This decorator caches each key/value
238-
of the dict-like object returned by the function. The keys of the returned data should match
239-
or be mappable to a sequence or iterable that is passed as an argument to the decorated
240-
callable. The name of that argument is passed to this decorator via the parameter
238+
of the dict-like object returned by the function. The dict keys of the returned data should
239+
match the set of keys that are passed to the decorated callable in an iterable object.
240+
The name of that argument is passed to this decorator via the parameter
241241
``keys_from_attr``. ``keys_from_attr`` can be the name of a positional or keyword argument.
242242
243243
If the argument specified by ``keys_from_attr`` is an empty list, the cache will be ignored
@@ -271,14 +271,13 @@ class multi_cached:
271271
happens in the background. Enabled by default
272272
273273
:param keys_from_attr: name of the arg or kwarg in the decorated callable that contains
274-
an iterable that corresponds to the keys returned by the decorated callable.
274+
an iterable that yields the keys returned by the decorated callable.
275275
:param namespace: string to use as default prefix for the key used in all operations of
276276
the backend. Default is None
277-
:param key_builder: Callable that enables mapping the ``keys_from_attr`` keys to the keys
278-
in the dict-like structure that is returned by the callable; executed before accessing
279-
the cache for storage/retrieval. Receives a key from the iterable corresponding to
280-
``keys_from_attr``, the callable, and the positional and keyword arguments that were
281-
passed to the decorated callable. This behavior is necessarily different than both
277+
:param key_builder: Callable that enables mapping the decorated function's keys to the keys
278+
used by the cache. Receives a key from the iterable corresponding to
279+
``keys_from_attr``, the decorated callable, and the positional and keyword arguments
280+
that were passed to the decorated callable. This behavior is necessarily different than
282281
``BaseCache.build_key()`` and the call signature differs from ``cached.key_builder``.
283282
:param ttl: int seconds to store the keys. Default is 0 which means no expiration.
284283
:param cache: cache class to use when calling the ``multi_set``/``multi_get`` operations.

0 commit comments

Comments
 (0)