21 lines
615 B
Go
21 lines
615 B
Go
package kvstore
|
|
|
|
// KVStore is a simple key-value store interface
|
|
type KVStore interface {
|
|
// Get retrieves a value for a given key. Returns nil if not found.
|
|
Get(key []byte) ([]byte, error)
|
|
|
|
// Set stores a value for a given key
|
|
Set(key []byte, value []byte) error
|
|
|
|
// Delete removes a key and its value
|
|
Delete(key []byte) error
|
|
|
|
// Close releases any resources held by the store
|
|
Close() error
|
|
|
|
// Scan iterates through all keys with the given prefix.
|
|
// For each key-value pair, fn is called. If fn returns false, iteration stops.
|
|
Scan(prefix []byte, fn func(key []byte, value []byte) bool) error
|
|
}
|