kv

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a WAL-based key-value store backed by FaultyStorage, with optional per-entry CRC32 checksums.

func NewStore

func NewStore(storage *detsim.FaultyStorage, checksums bool) *Store

NewStore creates a Store. If checksums is true, each WAL entry includes a CRC32 checksum that catches torn writes and byte corruption during recovery.

func (*Store) Get

func (s *Store) Get(key string) (string, bool)

Get retrieves the value for key from the in-memory index.

func (*Store) Len

func (s *Store) Len() int

Len returns the number of keys currently in the store.

func (*Store) Put

func (s *Store) Put(key, value string) (ok bool)

Put writes a key-value pair to the WAL. Returns false if the underlying storage is full (ErrDiskFull).

func (*Store) Recover

func (s *Store) Recover(maxOffset int64)

Recover replays the WAL from storage up to maxOffset, rebuilding the in-memory index. Entries with valid checksums are accepted; torn or corrupted entries stop the scan.

func (*Store) Sync

func (s *Store) Sync()

Sync commits all pending WAL writes to durable storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL