storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TempFileExtension is the extension for temporary files
	TempFileExtension = ".tmp"

	// StateKeyPrefix is the prefix for state keys in storage
	StateKeyPrefix = "state:"

	// SnapshotKeyPrefix is the prefix for snapshot keys in storage
	SnapshotKeyPrefix = "snapshot:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStorage

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

FileStorage implements a file-based storage backend Uses one file per key with atomic writes

func NewFileStorage

func NewFileStorage(basePath string) (*FileStorage, error)

NewFileStorage creates a new file-based storage

func (*FileStorage) BatchDelete

func (s *FileStorage) BatchDelete(keys [][]byte) error

BatchDelete removes multiple key-value pairs

func (*FileStorage) BatchGet

func (s *FileStorage) BatchGet(keys [][]byte) (map[string][]byte, error)

BatchGet retrieves multiple values

func (*FileStorage) BatchPut

func (s *FileStorage) BatchPut(items map[string][]byte) error

BatchPut stores multiple key-value pairs

func (*FileStorage) BeginTransaction

func (s *FileStorage) BeginTransaction() interfaces.Transaction

BeginTransaction creates a new transaction

func (*FileStorage) Close

func (s *FileStorage) Close() error

Close closes the storage

func (*FileStorage) Compact

func (s *FileStorage) Compact() error

Compact compacts the storage (no-op for simple file storage)

func (*FileStorage) Delete

func (s *FileStorage) Delete(key []byte) error

Delete removes a key-value pair

func (*FileStorage) Get

func (s *FileStorage) Get(key []byte) ([]byte, error)

Get retrieves a value by key

func (*FileStorage) GetStats

func (s *FileStorage) GetStats() interfaces.StorageStats

GetStats returns storage statistics

func (*FileStorage) Has

func (s *FileStorage) Has(key []byte) (bool, error)

Has checks if a key exists

func (*FileStorage) NewIterator

func (s *FileStorage) NewIterator(prefix []byte) interfaces.Iterator

NewIterator creates an iterator with optional prefix filtering

func (*FileStorage) Put

func (s *FileStorage) Put(key []byte, value []byte) error

Put stores a key-value pair

type MemoryStorage

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

MemoryStorage implements an in-memory storage backend

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

NewMemoryStorage creates a new in-memory storage

func (*MemoryStorage) BatchDelete

func (s *MemoryStorage) BatchDelete(keys [][]byte) error

BatchDelete removes multiple key-value pairs

func (*MemoryStorage) BatchGet

func (s *MemoryStorage) BatchGet(keys [][]byte) (map[string][]byte, error)

BatchGet retrieves multiple values

func (*MemoryStorage) BatchPut

func (s *MemoryStorage) BatchPut(items map[string][]byte) error

BatchPut stores multiple key-value pairs

func (*MemoryStorage) BeginTransaction

func (s *MemoryStorage) BeginTransaction() interfaces.Transaction

BeginTransaction creates a new transaction

func (*MemoryStorage) Close

func (s *MemoryStorage) Close() error

Close closes the storage (no-op for memory storage)

func (*MemoryStorage) Compact

func (s *MemoryStorage) Compact() error

Compact compacts the storage (no-op for memory storage)

func (*MemoryStorage) Delete

func (s *MemoryStorage) Delete(key []byte) error

Delete removes a key-value pair

func (*MemoryStorage) Get

func (s *MemoryStorage) Get(key []byte) ([]byte, error)

Get retrieves a value by key

func (*MemoryStorage) GetStats

func (s *MemoryStorage) GetStats() interfaces.StorageStats

GetStats returns storage statistics

func (*MemoryStorage) Has

func (s *MemoryStorage) Has(key []byte) (bool, error)

Has checks if a key exists

func (*MemoryStorage) NewIterator

func (s *MemoryStorage) NewIterator(prefix []byte) interfaces.Iterator

NewIterator creates an iterator with optional prefix filtering

func (*MemoryStorage) Put

func (s *MemoryStorage) Put(key []byte, value []byte) error

Put stores a key-value pair

Jump to

Keyboard shortcuts

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