mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
Merge pull request #15299 from AUTOMATIC1111/diskcache-bett
Tweak diskcache limits
This commit is contained in:
commit
8ac4a207f3
@ -20,6 +20,14 @@ def dump_cache():
|
||||
pass
|
||||
|
||||
|
||||
def make_cache(subsection: str) -> diskcache.Cache:
|
||||
return diskcache.Cache(
|
||||
os.path.join(cache_dir, subsection),
|
||||
size_limit=2**32, # 4 GB, culling oldest first
|
||||
disk_min_file_size=2**18, # keep up to 256KB in Sqlite
|
||||
)
|
||||
|
||||
|
||||
def convert_old_cached_data():
|
||||
try:
|
||||
with open(cache_filename, "r", encoding="utf8") as file:
|
||||
@ -37,7 +45,7 @@ def convert_old_cached_data():
|
||||
for subsection, keyvalues in data.items():
|
||||
cache_obj = caches.get(subsection)
|
||||
if cache_obj is None:
|
||||
cache_obj = diskcache.Cache(os.path.join(cache_dir, subsection))
|
||||
cache_obj = make_cache(subsection)
|
||||
caches[subsection] = cache_obj
|
||||
|
||||
for key, value in keyvalues.items():
|
||||
@ -64,7 +72,7 @@ def cache(subsection):
|
||||
|
||||
cache_obj = caches.get(subsection)
|
||||
if not cache_obj:
|
||||
cache_obj = diskcache.Cache(os.path.join(cache_dir, subsection))
|
||||
cache_obj = make_cache(subsection)
|
||||
caches[subsection] = cache_obj
|
||||
|
||||
return cache_obj
|
||||
|
Loading…
Reference in New Issue
Block a user