github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/cluster/key_value_store.go (about) 1 package cluster 2 3 import "golang.org/x/net/context" 4 5 // KeyValueStore is a distributed key value store 6 type KeyValueStore[T any] interface { 7 // Set the value for the given key. 8 Set(ctx context.Context, key string, value T) error 9 // Get the value for the given key.. 10 Get(ctx context.Context, key string) (T, error) 11 // Clear the value for the given key. 12 Clear(ctx context.Context, key string) error 13 } 14 15 // EmptyKeyValueStore is a key value store that does nothing. 16 type EmptyKeyValueStore[T any] struct{} 17 18 func (e *EmptyKeyValueStore[T]) Set(_ context.Context, _ string, _ T) error { return nil } 19 20 func (e *EmptyKeyValueStore[T]) Get(_ context.Context, _ string) (T, error) { 21 var r T 22 return r, nil 23 } 24 25 func (e *EmptyKeyValueStore[T]) Clear(_ context.Context, _ string) error { return nil }