BORG_CACHE_IMPL environment variable added

BORG_CACHE_IMPL allows users to choose the client-side cache implementation from 'local', 'newcache' and 'adhoc'.
This commit is contained in:
Thomas Waldmann 2024-07-12 22:57:26 +02:00
parent 72be8eff15
commit 616af8daa8
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
3 changed files with 20 additions and 0 deletions

View File

@ -84,6 +84,16 @@ General:
- ``pyfuse3``: only try to load pyfuse3
- ``llfuse``: only try to load llfuse
- ``none``: do not try to load an implementation
BORG_CACHE_IMPL
Choose the implementation for the clientside cache, choose one of:
- ``local``: uses a persistent chunks cache and keeps it in a perfect state (precise refcounts and
sizes), requiring a potentially resource expensive cache sync in multi-client scenarios.
Also has a persistent files cache. Default implementation.
- ``adhoc``: builds a non-persistent chunks cache by querying the repo. Chunks cache contents
are somewhat sloppy for already existing chunks, concerning their refcount ("infinite") and
size (0). No files cache (slow, will chunk all input files). DEPRECATED.
- ``newcache``: Like ``adhoc``, but with a persistent files cache.
BORG_SELFTEST
This can be used to influence borg's builtin self-tests. The default is to execute the tests
at the beginning of each borg command invocation.

View File

@ -382,6 +382,15 @@ class Cache:
def adhoc():
return AdHocCache(manifest=manifest, lock_wait=lock_wait, iec=iec)
impl = os.environ.get("BORG_CACHE_IMPL", None)
if impl is not None:
methods = dict(local=local, newcache=newcache, adhoc=adhoc)
try:
method = methods[impl]
except KeyError:
raise RuntimeError("Unknown BORG_CACHE_IMPL value: %s" % impl)
return method()
if no_cache_sync_forced:
return adhoc() if prefer_adhoc_cache else newcache()

View File

@ -127,6 +127,7 @@ def archiver(tmp_path, set_env_variables):
archiver.patterns_file_path = os.fspath(tmp_path / "patterns")
os.environ["BORG_KEYS_DIR"] = archiver.keys_path
os.environ["BORG_CACHE_DIR"] = archiver.cache_path
# os.environ["BORG_CACHE_IMPL"] = "newcache"
os.mkdir(archiver.input_path)
os.chmod(archiver.input_path, 0o777) # avoid troubles with fakeroot / FUSE
os.mkdir(archiver.output_path)