@@ -1343,37 +1343,6 @@ cdef class Archive:
13431343 except RuntimeError as e:
13441344 raise KeyError(str(e))
13451345
1346- @property
1347- def cluster_cache_max_size(self) -> pyint:
1348- """ Maximum size of the cluster cache.
1349-
1350- Returns:
1351- (int ): maximum number of clusters stored in the cache.
1352- """
1353- return self.c_archive.getClusterCacheMaxSize()
1354-
1355- @cluster_cache_max_size.setter
1356- def cluster_cache_max_size(self, nb_clusters: pyint):
1357- """ Set the size of the cluster cache.
1358-
1359- If the new size is lower than the number of currently stored clusters
1360- some clusters will be dropped from cache to respect the new size.
1361-
1362- Args:
1363- nb_clusters (int ): maximum number of clusters stored in the cache
1364- """
1365-
1366- self.c_archive.setClusterCacheMaxSize(nb_clusters)
1367-
1368- @property
1369- def cluster_cache_current_size(self) -> pyint:
1370- """ Size of the cluster cache.
1371-
1372- Returns:
1373- (int ): number of clusters currently stored in the cache.
1374- """
1375- return self.c_archive.getClusterCacheCurrentSize()
1376-
13771346 @property
13781347 def dirent_cache_max_size(self) -> pyint:
13791348 """ Maximum size of the dirent cache.
@@ -1404,36 +1373,38 @@ cdef class Archive:
14041373 """
14051374 return self.c_archive.getDirentCacheCurrentSize()
14061375
1407- @property
1408- def dirent_lookup_cache_max_size(self) -> pyint:
1409- """ Size of the dirent lookup cache.
1376+ def __repr__(self) -> str:
1377+ return f"{self.__class__.__name__}(filename={self.filename})"
14101378
1411- The returned size returns the default size or the last set size.
1412- This may not correspond to the actual size of the dirent lookup cache.
1413- See set_dirent_lookup_cache_max_size for more information.
14141379
1415- Returns:
1416- (int ): maximum number of sub ranges created in the lookup cache.
1417- """
1418- return self.c_archive.getDirentLookupCacheMaxSize()
1380+ def get_cluster_cache_max_size() -> pyint:
1381+ """ Get the maximum size of the cluster cache.
14191382
1420- @dirent_lookup_cache_max_size.setter
1421- def dirent_lookup_cache_max_size(self, nb_ranges: pyint):
1422- """ Set the size of the dirent lookup cache.
1383+ Returns:
1384+ (int ): the maximum memory size used by the cluster cache (in bytes).
1385+ """
1386+ return zim.getClusterCacheMaxSize()
14231387
1424- Contrary to other set_< foo> _cache_max_size, this method is useless
1425- once the lookup cache is created.
1426- The lookup cache is created at first access to a entry in the archive.
1427- So this method must be called before any access to content (including metadata).
1428- It is best to call this method first, just after the archive creation.
1388+ def set_cluster_cache_max_size(size_in_bytes: pyint):
1389+ """ Set the size of the cluster cache.
14291390
1430- Args:
1431- nb_ranges (int ): maximum number of sub ranges created in the lookup cache.
1432- """
1433- self.c_archive.setDirentLookupCacheMaxSize(nb_ranges)
1391+ If the new size is lower than the number of currently stored clusters
1392+ some clusters will be dropped from cache to respect the new size.
1393+
1394+ Args:
1395+ size_in_bytes (int ): the memory limit (in bytes) for the cluster cache.
1396+ """
1397+
1398+ zim.setClusterCacheMaxSize(nb_clusters)
1399+
1400+ def get_cluster_cache_current_size() -> pyint:
1401+ """ Get the current size of the cluster cache.
1402+
1403+ Returns:
1404+ (int ): the current memory size (in bytes) used by the cluster cache.
1405+ """
1406+ return zim.getClusterCacheCurrentSize()
14341407
1435- def __repr__(self) -> str:
1436- return f"{self.__class__.__name__}(filename={self.filename})"
14371408
14381409reader_module_doc = """ libzim reader module
14391410
@@ -1453,6 +1424,9 @@ reader_public_objects = [
14531424 Archive,
14541425 Entry,
14551426 Item,
1427+ get_cluster_cache_max_size,
1428+ set_cluster_cache_max_size,
1429+ get_cluster_cache_current_size,
14561430]
14571431reader = create_module(reader_module_name, reader_module_doc, reader_public_objects)
14581432
0 commit comments