Interface BlobCache
- All Superinterfaces:
AutoCloseable
Caches immutable, server-addressed blob payloads on local disk.
open(BlobCacheConfig) uses the shared Rust DXBC implementation through JNI. Cache methods are
synchronous and safe to share through a Client and Worker. A missing or rejected
entry is a normal cache outcome; the server remains the source of truth. Close the cache after
every client and worker using it has stopped.
try (BlobCache cache = BlobCache.open(
new BlobCacheConfig("./dex-cache", 256L * 1024 * 1024))) {
boolean cached = cache.put(blobId, payload);
Optional<byte[]> value = cache.get(blobId);
}
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Flushes pending cache work and releases native resources.voidDeletes one cached blob if present.voidDeletes all entries managed by this cache.Optional<byte[]> Reads and validates one cached blob.static BlobCacheopen(BlobCacheConfig config) Opens or recovers a disk-backed blob cache.booleanOffers one payload to the cache's admission policy.
-
Method Details
-
open
Opens or recovers a disk-backed blob cache.- Parameters:
config- the cache directory, capacity, and admission configuration- Returns:
- the opened cache
- Throws:
IllegalArgumentException- ifconfigisnullRuntimeException- if the native library cannot load or the cache cannot open
-
get
Reads and validates one cached blob.- Parameters:
blobId- the server-minted blob identifier- Returns:
- a copy of the payload, or an empty value for a cache miss
- Throws:
RuntimeException- if cache storage cannot be read
-
put
Offers one payload to the cache's admission policy.- Parameters:
blobId- the server-minted blob identifierpayload- the immutable payload bytes to cache- Returns:
truewhen admitted and stored;falsewhen policy rejects the entry- Throws:
RuntimeException- if cache storage cannot be written
-
delete
Deletes one cached blob if present.- Parameters:
blobId- the server-minted blob identifier- Throws:
RuntimeException- if cache storage cannot complete the deletion
-
deleteAll
void deleteAll()Deletes all entries managed by this cache.- Throws:
RuntimeException- if cache storage cannot complete all deletions
-
close
void close()Flushes pending cache work and releases native resources.Do not call other methods after closing the cache.
- Specified by:
closein interfaceAutoCloseable
-