mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-25 11:39:12 +08:00
37234bf3f8
can compile now, need to implement those unimplemented
43 lines
825 B
Go
43 lines
825 B
Go
package redis2
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
|
"github.com/go-redis/redis"
|
|
)
|
|
|
|
func (store *UniversalRedis2Store) KvPut(ctx context.Context, key []byte, value []byte) (err error) {
|
|
|
|
_, err = store.Client.Set(string(key), value, 0).Result()
|
|
|
|
if err != nil {
|
|
return fmt.Errorf("kv put: %v", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (store *UniversalRedis2Store) KvGet(ctx context.Context, key []byte) (value []byte, err error) {
|
|
|
|
data, err := store.Client.Get(string(key)).Result()
|
|
|
|
if err == redis.Nil {
|
|
return nil, filer.ErrKvNotFound
|
|
}
|
|
|
|
return []byte(data), err
|
|
}
|
|
|
|
func (store *UniversalRedis2Store) KvDelete(ctx context.Context, key []byte) (err error) {
|
|
|
|
_, err = store.Client.Del(string(key)).Result()
|
|
|
|
if err != nil {
|
|
return fmt.Errorf("kv delete: %v", err)
|
|
}
|
|
|
|
return nil
|
|
}
|