Documentation
¶
Overview ¶
Package fs provides a filesystem-based implementation of kvstore.KVStore. Keys are sharded into subdirectories using the first 2 hex characters, similar to Git's object storage layout.
Index ¶
- type KV
- func (k *KV) Batch() kvstore.Batch
- func (k *KV) BatchGet(ctx context.Context, keys [][]byte) (map[string][]byte, error)
- func (k *KV) Close() error
- func (k *KV) Delete(ctx context.Context, key []byte) error
- func (k *KV) Get(ctx context.Context, key []byte) ([]byte, error)
- func (k *KV) Has(ctx context.Context, key []byte) (bool, error)
- func (k *KV) NewIterator(ctx context.Context, start, end []byte) kvstore.Iterator
- func (k *KV) Put(ctx context.Context, key, value []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KV ¶
type KV struct {
// contains filtered or unexported fields
}
KV is a filesystem-based implementation of kvstore.KVStore. Keys are stored as files in a sharded directory structure:
root/ ├── ab/ # key hex prefix "ab" │ └── cdef... # remaining hex as filename ├── cd/ │ └── ef12...
func New ¶
New creates a new filesystem KV store at the given root directory. The directory is created if it doesn't exist.
func (*KV) BatchGet ¶
BatchGet retrieves multiple values by keys using parallel file reads. Uses errgroup for concurrent I/O with a limit of 8 parallel reads. File not found errors are skipped; other errors (permission, I/O) stop the operation.
func (*KV) NewIterator ¶
NewIterator creates an iterator over a range of keys. Note: filesystem iterator is less efficient than in-memory or database-based iterators.