MCPcopy Create free account
hub / github.com/PRBonn/vdbfusion / wrapper

Function wrapper

examples/python/utils/cache.py:22–34  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

20
21 @ft.wraps(func)
22 def wrapper(*args, **kwargs):
23 cls = args[0]
24 if not cls.use_cache:
25 return func(*args, **kwargs)
26 key = wrapper.__cache_key__(*args[1:], **kwargs)
27 result = cls.cache.get(key, default=ENOVAL, retry=True)
28
29 if result is ENOVAL:
30 result = func(*args, **kwargs)
31 if expire is None or expire > 0:
32 cls.cache.set(key, result, expire, tag=tag, retry=True)
33
34 return result
35
36 def __cache_key__(*args, **kwargs):
37 """Make key for cache given function arguments."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected