Class BlobCacheConfig
BlobCache.
The byte capacity limits admitted cache contents; it is not a durable-storage quota or a guarantee that every offered blob will be retained.
frequencyCounters controls the requested number of 4-bit access counters in the
in-memory TinyLFU sketch that approximately tracks how often blob IDs are accessed. The cache
uses these estimates to prefer frequently reused blobs over one-use blobs when admitting or
evicting data. It is not the maximum number of cached blobs, an exact access-history length, or
part of the disk-capacity calculation.
A larger value uses more process memory but reduces collisions between unrelated blob IDs,
making admission and eviction decisions more accurate. A smaller value saves memory, but scan
traffic can make cold blobs appear hotter than they are and reduce the expected cache hit ratio.
The value does not affect cache correctness, file integrity, or maxBytes enforcement.
Access history is not preserved across cache reopenings.
Use approximately ten counters per blob that the cache is expected to hold when full. For
example, if maxBytes usually holds about 1,000 blobs, 10,000 counters is a reasonable
starting point. The policy uses approximately three bytes of memory per requested counter before
internal rounding, so requesting 10,000 counters represents about 30 KB before rounding; actual
memory use can be higher. Increase the value for a much larger expected item count or a workload
with substantial one-use scan traffic. Decrease it only when policy memory matters more than
admission accuracy. Passing zero uses the default of 10,000.
BlobCacheConfig config = new BlobCacheConfig(
"./dex-cache",
256L * 1024 * 1024,
10_000L);
-
Constructor Summary
ConstructorsConstructorDescriptionBlobCacheConfig(String directory, long maxBytes) Creates a configuration with 10,000 frequency counters.BlobCacheConfig(String directory, long maxBytes, long frequencyCounters) Creates a configuration with an explicit admission-sketch size. -
Method Summary
-
Constructor Details
-
BlobCacheConfig
Creates a configuration with 10,000 frequency counters.- Parameters:
directory- the nonempty directory used for cache filesmaxBytes- the positive maximum admitted payload size in bytes- Throws:
IllegalArgumentException- if the directory is empty or the capacity is not positive
-
BlobCacheConfig
Creates a configuration with an explicit admission-sketch size.- Parameters:
directory- the nonempty directory used for cache filesmaxBytes- the positive maximum admitted payload size in bytesfrequencyCounters- the nonnegative TinyLFU sketch size described above; zero uses the default of 10,000- Throws:
IllegalArgumentException- if the directory is empty, the capacity is not positive, orfrequencyCountersis negative
-