Skip to content

Commit

Permalink
try using tiled cache
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Aug 28, 2024
1 parent 0f74562 commit f82c450
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/silx/io/tiledh5.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from . import commonh5
import h5py
import tiled.client
from tiled.client.cache import Cache


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -83,6 +84,9 @@ class TiledH5(commonh5.File):
Set to None for allowing an unbound number of children per group.
"""

_cache = None
"""Shared tiled cache with lazy initialization"""

def __init__(
self,
name: str,
Expand All @@ -91,7 +95,9 @@ def __init__(
):
assert mode in ("r", None)
super().__init__(name, mode, attrs)
self.__container = tiled.client.from_uri(name)
if self._cache is None:
TiledH5._cache = Cache() # Use tiled cache default
self.__container = tiled.client.from_uri(name, cache=self._cache)
assert isinstance(self.__container, tiled.client.container.Container)

def close(self):
Expand Down

0 comments on commit f82c450

Please sign in to comment.