Documentation
¶
Overview ¶
Package writer provides a durable raw-chunk cache. Namespace references are the recovery log: referenced raw chunks are pinned until their backend replacement is committed and the metadata log has been synced.
Index ¶
- type Stats
- type Store
- func (s *Store) Close() error
- func (s *Store) OpenChunk(key string) (*os.File, bool, error)
- func (s *Store) PutClean(ctx context.Context, key string, data []byte) (bool, error)
- func (s *Store) PutPin(ctx context.Context, key string, data []byte) error
- func (s *Store) Recover(pins map[string]int) error
- func (s *Store) Stats() Stats
- func (s *Store) UnderPressure() bool
- func (s *Store) Unpin(key string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stats ¶
type Stats struct {
CapacityBytes int64 `json:"capacity_bytes"`
UsedBytes int64 `json:"used_bytes"`
DirtyBytes int64 `json:"dirty_bytes"`
DirtyChunks int64 `json:"dirty_chunks"`
CleanBytes int64 `json:"clean_bytes"`
ReservedBytes int64 `json:"reserved_bytes"`
CleanPutBytes int64 `json:"clean_put_bytes"`
PutBytes int64 `json:"put_bytes"`
PutNanos int64 `json:"put_nanos"`
WaitNanos int64 `json:"wait_nanos"`
Evictions int64 `json:"evictions"`
ReadHits int64 `json:"read_hits"`
ReadMisses int64 `json:"read_misses"`
Waiters int64 `json:"waiters"`
DirectorySyncs int64 `json:"directory_syncs"`
DirectorySyncNanos int64 `json:"directory_sync_nanos"`
DirectoryCoalesced int64 `json:"directory_coalesced"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func Open ¶
Open takes an exclusive process lock. owner identifies the metadata store; using another namespace's cache is rejected rather than evicting its data. Call Recover before serving requests or adding chunks.
func (*Store) OpenChunk ¶
OpenChunk opens under the eviction lock. An unlinked clean object remains readable through the returned fd until the caller closes it.
func (*Store) PutClean ¶
PutClean opportunistically publishes verified decoded data without a pin. It never waits for capacity, another publisher, or dirty writers, and never evicts existing cache data. Five percent (at least one incoming chunk) stays free for dirty admission. False means an existing object or pressure skipped the fill. A successful fill uses the same crash-safe publication as PutPin.
func (*Store) PutPin ¶
PutPin writes one immutable chunk and makes it durable BEFORE it can be referenced by the metadata log. Full dirty caches apply cancellable pressure to writers; background workers can continue reading and unpinning chunks.
func (*Store) Recover ¶
Recover pins all raw references before any clean-cache eviction. Missing dirty data prevents mounting; it must never turn into a sparse zero chunk.
func (*Store) UnderPressure ¶
UnderPressure reports blocked disk admission so the uploader can expedite metadata retirement instead of waiting for the periodic group commit.