github.com/blong14/gache@v0.0.0-20240124023949-89416fd8bbfa/internal/db/kv.go (about) 1 package db 2 3 import "encoding/json" 4 5 type KV[K, V any] interface { 6 Get(k K) (V, bool) 7 Range(func(k K, v V) bool) 8 Remove(k K) (V, bool) 9 Set(k K, v V) 10 } 11 12 type KeyValue struct { 13 Key json.RawMessage `json:"key"` 14 Value json.RawMessage `json:"value"` 15 } 16 17 func (kv *KeyValue) Valid() bool { 18 return len(kv.Key) > 0 19 }