Skip to content

Commit 507b3a5

Browse files
authored
functions to get cache information (#281)
* get cache information - close #280 * update changelog
1 parent 9f881ef commit 507b3a5

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* update docs for 8.12 [jcupitt]
88
* add pagesplit(), pagejoin(), get_page_height(), get_n_pages() [jcupitt]
99
* add atan2() [jcupitt]
10+
* add `cache_get_max()`, `cache_get_max_mem()`, `cache_get_max_files()`,
11+
`cache_get_size()` [hroskes]
1012
* don't generate docs for deprecated arguments [jcupitt]
1113
* buffer save tries with the target API first [jcupitt]
1214

pyvips/vdecls.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ def cdefs(features):
383383
void vips_cache_set_max_files (int max_files);
384384
void vips_cache_set_trace (int trace);
385385
386+
int vips_cache_get_max();
387+
int vips_cache_get_size();
388+
size_t vips_cache_get_max_mem();
389+
int vips_cache_get_max_files();
386390
'''
387391

388392
if _at_least(features, 8, 5):

pyvips/voperation.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,30 @@ def cache_set_trace(trace):
564564
vips_lib.vips_cache_set_trace(trace)
565565

566566

567+
def cache_get_max():
568+
"""Get the maximum number of operations libvips will cache."""
569+
return vips_lib.vips_cache_get_max()
570+
571+
572+
def cache_get_size():
573+
"""Get the current size of the operations cache."""
574+
return vips_lib.vips_cache_get_size()
575+
576+
577+
def cache_get_max_mem():
578+
"""Get the operation cache limit by memory use."""
579+
return vips_lib.vips_cache_get_max_mem()
580+
581+
582+
def cache_get_max_files():
583+
"""Get the operation cache limit by number of open files."""
584+
return vips_lib.vips_cache_get_max_files()
585+
586+
567587
__all__ = [
568588
'Introspect', 'Operation',
569589
'cache_set_max', 'cache_set_max_mem', 'cache_set_max_files',
570-
'cache_set_trace'
590+
'cache_set_trace',
591+
'cache_get_max', 'cache_get_max_mem', 'cache_get_max_files',
592+
'cache_get_size',
571593
]

0 commit comments

Comments
 (0)