pub struct DiskCache<'directory, 'buffer> { /* private fields */ }Expand description
One bounded resident buffer backed by immutable cache files. Each get
reloads its file so eviction and corrupt entries remain visible. The core
selected writer validates every returned pack before output. Oversized files
fail before reading into the buffer; no pack-sized allocation or mapping is
performed here. A host may open independent instances for concurrent readers.
Implementations§
Source§impl DiskCache<'_, '_>
impl DiskCache<'_, '_>
Sourcepub fn try_lease(&self, key: Key) -> Result<Option<Lease>>
pub fn try_lease(&self, key: Key) -> Result<Option<Lease>>
Attempt one nonblocking exclusive lock for a selected key. None means
the cache is disabled or another cooperative producer holds the lock.
After acquisition, recheck the cache before generating a pack: another
producer may have completed while this request waited to retry.
Authorization and selection remain mandatory before every lookup.
Guards own independent close-on-exec descriptors and do not borrow the
backend, so the host can call the selected writer while holding one.
Eviction affects .pack files only and never removes the lock identity.
Source§impl<'directory, 'buffer> DiskCache<'directory, 'buffer>
impl<'directory, 'buffer> DiskCache<'directory, 'buffer>
Sourcepub fn new(
directory: BorrowedFd<'directory>,
buffer: &'buffer mut [u8],
nonce: [u8; 16],
) -> Self
pub fn new( directory: BorrowedFd<'directory>, buffer: &'buffer mut [u8], nonce: [u8; 16], ) -> Self
Supply a trusted directory descriptor, fixed resident bytes, and a host-chosen nonce unique among concurrent producers in that directory. Exclusive staging-file creation safely rejects nonce/name collisions.