Skip to content

Commit

Permalink
Add a utility function to minimize caching
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Aug 28, 2024
1 parent 72fce80 commit 76b83dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Speed up getting plottable data from adjacent items; plot more data ([#1613](../../pull/1613), [#1614](../../pull/1614))
- Better handle mixed dtype sources in the multi source ([#1616](../../pull/1616))
- Add a utility function to minimize caching ([#1617](../../pull/1617))

### Bug Fixes

Expand Down
14 changes: 14 additions & 0 deletions large_image/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,17 @@ def total_memory() -> int:
if mem:
return mem
return 8 * 1024 ** 3


def minimizeCaching(mode=None):
"""
Set python cache sizes to very low values.
:param mode: None for all caching, 'tile' for the tile cache, 'source' for
the source cache.
"""
if not mode or str(mode).lower().startswith('source'):
setConfig('cache_tilesource_maximum', 1)

Check warning on line 198 in large_image/config.py

View check run for this annotation

Codecov / codecov/patch

large_image/config.py#L198

Added line #L198 was not covered by tests
if not mode or str(mode).lower().startswith('tile'):
setConfig('cache_backend', 'python')
setConfig('cache_python_memory_portion', 256)

Check warning on line 201 in large_image/config.py

View check run for this annotation

Codecov / codecov/patch

large_image/config.py#L200-L201

Added lines #L200 - L201 were not covered by tests

0 comments on commit 76b83dc

Please sign in to comment.