Skip to content

Commit 14527e9

Browse files
Control on-disk cache size with env var WPE_DISK_CACHE_SIZE
1 parent 7789c4b commit 14527e9

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Source/WebKit/Shared/CacheModel.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <wtf/RAMSize.h>
3131
#include <wtf/Seconds.h>
3232
#include <wtf/StdLibExtras.h>
33+
#include <wtf/text/WTFString.h>
34+
#include <wtf/text/StringToIntegerConversion.h>
3335

3436
namespace WebKit {
3537

@@ -170,6 +172,21 @@ uint64_t calculateURLCacheDiskCapacity(CacheModel cacheModel, uint64_t diskFreeS
170172
ASSERT_NOT_REACHED();
171173
};
172174

175+
auto s = String::fromLatin1(getenv("WPE_DISK_CACHE_SIZE"));
176+
if (!s.isEmpty()) {
177+
String value = s.trim(deprecatedIsSpaceOrNewline).convertToLowercaseWithoutLocale();
178+
size_t units = 1;
179+
if (value.endsWith('k'))
180+
units = KB;
181+
else if (value.endsWith('m'))
182+
units = MB;
183+
if (units != 1)
184+
value = value.substring(0, value.length()-1);
185+
186+
size_t size = size_t(parseInteger<uint64_t>(s).value_or(1) * units);
187+
urlCacheDiskCapacity = (unsigned long)(size);
188+
}
189+
173190
return urlCacheDiskCapacity;
174191
}
175192

0 commit comments

Comments
 (0)