-
Notifications
You must be signed in to change notification settings - Fork 50
/
empty.go
51 lines (38 loc) · 1.1 KB
/
empty.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package kvstore
import (
"context"
"fmt"
"github.com/justtrackio/gosoline/pkg/refl"
)
type emptyKvStore[T any] struct{}
func NewEmptyKvStore[T any]() KvStore[T] {
return NewEmptyKvStoreWithInterfaces[T]()
}
func NewEmptyKvStoreWithInterfaces[T any]() KvStore[T] {
return &emptyKvStore[T]{}
}
func (s *emptyKvStore[T]) Contains(_ context.Context, _ any) (bool, error) {
return false, nil
}
func (s *emptyKvStore[T]) Get(_ context.Context, _ any, _ *T) (bool, error) {
return false, nil
}
func (s *emptyKvStore[T]) GetBatch(_ context.Context, keys any, _ any) ([]interface{}, error) {
missing, err := refl.InterfaceToInterfaceSlice(keys)
if err != nil {
return nil, fmt.Errorf("could not convert keys from %T to []interface{}: %w", keys, err)
}
return missing, nil
}
func (s *emptyKvStore[T]) Put(_ context.Context, _ any, _ T) error {
return nil
}
func (s *emptyKvStore[T]) PutBatch(_ context.Context, _ any) error {
return nil
}
func (s *emptyKvStore[T]) Delete(_ context.Context, _ any) error {
return nil
}
func (s *emptyKvStore[T]) DeleteBatch(_ context.Context, _ any) error {
return nil
}