@@ -33,6 +33,29 @@ def cache_selfie(
3333 else :
3434 raise TypeError ("Invalid arguments provided to cache_selfie" )
3535
36+ def cache_selfie_json (to_cache : Callable [..., T ]) -> "CacheSelfie[T]" :
37+ return cache_selfie (to_cache , Roundtrip .json ())
38+
39+ @overload
40+ def cache_selfie_binary (to_cache : Callable [..., bytes ]) -> "CacheSelfieBinary[bytes]" : ...
41+
42+ @overload
43+ def cache_selfie_binary (
44+ to_cache : Callable [..., T ], roundtrip : Roundtrip [T , bytes ]
45+ ) -> "CacheSelfieBinary[T]" : ...
46+
47+ def cache_selfie_binary (
48+ to_cache : Union [Callable [..., bytes ], Callable [..., T ]],
49+ roundtrip : Optional [Roundtrip [T , bytes ]] = None ,
50+ ) -> Union ["CacheSelfieBinary[bytes]" , "CacheSelfieBinary[T]" ]:
51+ if roundtrip is None :
52+ # the cacheable better be a bytes!
53+ return cache_selfie_binary (to_cache , Roundtrip .identity ()) # type: ignore
54+ elif isinstance (roundtrip , Roundtrip ) and to_cache is not None :
55+ deferred_disk_storage = _selfieSystem ().disk_thread_local ()
56+ return CacheSelfieBinary (deferred_disk_storage , roundtrip , to_cache ) # type: ignore
57+ else :
58+ raise TypeError ("Invalid arguments provided to cache_selfie" )
3659
3760class CacheSelfie (Generic [T ]):
3861 def __init__ (
0 commit comments