feat(repository): added hard size limit to the on-disk cache (#3238)

* test(providers): added capacity limits to blobtesting.mapStorage

* refactor(general): added mutex map which dynamically allocates and releases named mutexes

* refactor(repository): refactored cache cleanup and limit enforcement

* refactor(repository): plumb through cache size limits in the repository

* feat(cli): added CLI options to set cache size limits

* unified flag setting and field naming

* Update cli/command_cache_set.go

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>

* pr feedback

---------

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
This commit is contained in:
Jarek KowalskiandShikhar Mall authored and GitHub committed 2023-08-24 09:38:56 -07:00
1 parent 1fd1ff0151
commit fe55dcb6a2
20 files changed
+654 -295

No files matched your search

+10 -2
View File
@@ -30,13 +30,21 @@ func TestCacheSet(t *testing.T) {
"cache", "set",
"--cache-directory", ncd,
"--content-cache-size-mb=33",
"--content-cache-size-limit-mb=331",
"--metadata-cache-size-mb=44",
"--metadata-cache-size-limit-mb=441",
)
out := env.RunAndExpectSuccess(t, "cache", "info")
require.Contains(t, mustGetLineContaining(t, out, "33 MB"), ncd)
require.Contains(t, mustGetLineContaining(t, out, "33 MB"), "contents")
require.Contains(t, mustGetLineContaining(t, out, "44 MB"), "metadata")
require.Contains(t, mustGetLineContaining(t, out, "soft limit: 33 MB"), "contents")
require.Contains(t, mustGetLineContaining(t, out, "hard limit: 331 MB"), "contents")
require.Contains(t, mustGetLineContaining(t, out, "min sweep age: 10m0s"), "contents")
require.Contains(t, mustGetLineContaining(t, out, "soft limit: 44 MB"), "metadata")
require.Contains(t, mustGetLineContaining(t, out, "hard limit: 441 MB"), "metadata")
require.Contains(t, mustGetLineContaining(t, out, "min sweep age: 24h0m0s"), "metadata")
require.Contains(t, mustGetLineContaining(t, out, "55s"), "blob-list")
}