mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-29 19:05:05 +08:00
Tweak diskcache limits
This commit is contained in:
parent
f1b090e9e0
commit
df4da02ab0
@ -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