Suggested use case:
@cached_many(cache)
def expensive_function(items: Iterable[K], …) -> Mapping[K, V]:
…
expensive_function(["foo", "bar", "qux"], …)
Expected behaviour
expensive_function should get called only on items which aren't present in the cache. Pseudo-code:
cached_items = cache.get_many(*items)
new_items = wrapped_function(*(item for item in items if item not in cached_items), *args, **kwargs)
cache.set_many(new_items)
return {**cached_items, **new_items}
Discussion
- Should
@cached_many allow specifying of the items parameter by index or keyword argument name?
Suggested use case:
Expected behaviour
expensive_functionshould get called only on items which aren't present in the cache. Pseudo-code:Discussion
@cached_manyallow specifying of theitemsparameter by index or keyword argument name?