Skip to content

Commit 22abb03

Browse files
committed
Add set_cache_tll
1 parent 24fc595 commit 22abb03

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

phiml/dataclasses/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@
4747
from ._dataclasses import sliceable, data_fields, non_data_fields, config_fields, special_fields, replace, copy, getitem, equal, data_eq
4848

4949
from ._parallel import parallel_compute, parallel_property
50-
from ._tensor_cache import on_load_into_memory, get_cache_files
50+
from ._tensor_cache import on_load_into_memory, get_cache_files, set_cache_tll
5151

5252
__all__ = [key for key in globals().keys() if not key.startswith('_')]

phiml/dataclasses/_tensor_cache.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,11 @@ def cleaner():
250250

251251

252252
_CACHE = SoftCache(2., [])
253+
254+
255+
def set_cache_tll(ttl_seconds: float):
256+
"""
257+
Sets the time to live (TTL) for data loaded into memory for disk-backed tensors.
258+
This function should be called before the tensor cache is used.
259+
"""
260+
_CACHE.ttl = ttl_seconds

0 commit comments

Comments
 (0)