Get or create ShardedLMDBManager singleton. Args: cache_dir: Cache directory path. num_shards: Number of shards. map_size_per_shard: Maximum size per shard. readonly: Read-only mode flag. lock: File locking flag. logger
(
cls,
cache_dir: str,
num_shards: int = 32,
map_size_per_shard: int = 1024 * 1024 * 1024 * 1024,
readonly: bool = False,
lock: bool = True,
logger=None,
max_open_shards: int = 0,
)
| 147 | |
| 148 | @classmethod |
| 149 | def get_instance( |
| 150 | cls, |
| 151 | cache_dir: str, |
| 152 | num_shards: int = 32, |
| 153 | map_size_per_shard: int = 1024 * 1024 * 1024 * 1024, |
| 154 | readonly: bool = False, |
| 155 | lock: bool = True, |
| 156 | logger=None, |
| 157 | max_open_shards: int = 0, |
| 158 | ) -> "ShardedLMDBManager": |
| 159 | """Get or create ShardedLMDBManager singleton. |
| 160 | |
| 161 | Args: |
| 162 | cache_dir: Cache directory path. |
| 163 | num_shards: Number of shards. |
| 164 | map_size_per_shard: Maximum size per shard. |
| 165 | readonly: Read-only mode flag. |
| 166 | lock: File locking flag. |
| 167 | logger: Logger instance. |
| 168 | max_open_shards: Maximum open shards (0 = no limit). |
| 169 | |
| 170 | Returns: |
| 171 | ShardedLMDBManager instance for the given cache_dir. |
| 172 | """ |
| 173 | cache_dir = os.path.abspath(os.path.expanduser(cache_dir)) |
| 174 | |
| 175 | if cache_dir not in cls._instances: |
| 176 | cls._instances[cache_dir] = cls( |
| 177 | cache_dir=cache_dir, |
| 178 | num_shards=num_shards, |
| 179 | map_size_per_shard=map_size_per_shard, |
| 180 | readonly=readonly, |
| 181 | lock=lock, |
| 182 | logger=logger, |
| 183 | max_open_shards=max_open_shards, |
| 184 | ) |
| 185 | return cls._instances[cache_dir] |
| 186 | |
| 187 | def _get_shard_path(self, shard_id: int) -> str: |
| 188 | """Get path to shard directory.""" |
nothing calls this directly
no outgoing calls
no test coverage detected