33"""
44
55from pathlib import Path
6- from collections import defaultdict
76
87# Import constants using full package name for compatibility with nbdkit and pytest
98from blkcache .constants import (
10- STATUS_UNTRIED ,
119 DEFAULT_BLOCK_SIZE ,
1210)
1311
14- # Import Cache class
15- from blkcache .cache .cache import Cache
12+ # Import BlockCache class
13+ from blkcache .cache .through import BlockCache
1614
1715# Global state
1816DEV : Path | None = None
1917CACHE : Path | None = None
2018BLOCK = DEFAULT_BLOCK_SIZE # Use constant for default block size
2119METADATA = {}
22- BLOCK_STATUS = defaultdict (lambda : STATUS_UNTRIED )
2320
2421# Cache instance - will be created in config_complete
2522CACHE_INSTANCE = None
@@ -51,15 +48,14 @@ def config(key: str, val: str) -> None:
5148
5249def config_complete () -> None :
5350 """Validates required parameters and initializes the cache implementation."""
54- global DEV , CACHE , BLOCK , METADATA , BLOCK_STATUS , CACHE_INSTANCE
51+ global DEV , CACHE , BLOCK , METADATA , CACHE_INSTANCE
5552
5653 if DEV is None or CACHE is None :
5754 raise RuntimeError ("device= and cache= are required" )
5855
5956 # Create a BlockCache instance
60- CACHE_INSTANCE = BlockCache (
61- device_path = DEV , cache_path = CACHE , block_size = BLOCK if BLOCK != DEFAULT_BLOCK_SIZE else None
62- )
57+ config = {"device_path" : DEV , "cache_path" : CACHE , "block_size" : BLOCK if BLOCK != DEFAULT_BLOCK_SIZE else None }
58+ CACHE_INSTANCE = BlockCache (config )
6359
6460 # The BlockCache initialization will handle:
6561 # - Loading the mapfile if it exists
@@ -68,8 +64,7 @@ def config_complete() -> None:
6864
6965 # Keep using the legacy variables for now to minimize changes
7066 BLOCK = CACHE_INSTANCE .block_size
71- METADATA = CACHE_INSTANCE .metadata
72- BLOCK_STATUS = CACHE_INSTANCE .block_status
67+ METADATA = CACHE_INSTANCE .diskmap .config
7368
7469
7570def open (_readonly : bool ) -> dict [str , int ]:
0 commit comments