You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/05/02 21:51:38 UTC
[GitHub] [superset] eschutho commented on a diff in pull request #19930: fix: memoize primitives
eschutho commented on code in PR #19930:
URL: https://github.com/apache/superset/pull/19930#discussion_r863215977
##########
superset/utils/cache.py:
##########
@@ -98,7 +98,18 @@ def memoized_func(
key: Optional[str] = None,
cache: Cache = cache_manager.cache,
) -> Callable[..., Any]:
- """Use this decorator to cache functions that have predefined first arg.
+ """
+ Decorator with configurable key and cache backend.
+
+ @memoized_func(key="{a}+{b}", cache=cache_manager.data_cache)
+ def sum(a: int, b: int) -> int:
+ return a + b
+
+ In the example above the result for `1+2` will be stored under the key of name "1+2",
+ in the `cache_manager.data_cache` cache.
+
+ Note: this decorator should be used only with functions that return primitives,
Review Comment:
yey!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org