diff --git a/storage/dao/dao.go b/storage/dao/dao.go index 6e8eb70..8cd9b04 100644 --- a/storage/dao/dao.go +++ b/storage/dao/dao.go @@ -3,6 +3,7 @@ package dao import ( "gitee.com/timedb/wheatCache/pkg/errorx" "gitee.com/timedb/wheatCache/pkg/lru" + "gitee.com/timedb/wheatCache/pkg/proto" "gitee.com/timedb/wheatCache/pkg/structure" "gitee.com/timedb/wheatCache/pkg/structure/stringx" ) @@ -17,7 +18,7 @@ func NewDao(lru lru.CacheInterface) *Dao { } } -func (d *Dao) Set(key string, strVal string) (string, error) { +func (d *Dao) Set(key *proto.BaseKey, strVal string) (string, error) { value, ok := d.lru.Get(key) if ok { if val, ok := value.(structure.StringXInterface); ok { @@ -37,10 +38,10 @@ func (d *Dao) Set(key string, strVal string) (string, error) { return result, nil } -func (d *Dao) Get(key string) (string, error) { +func (d *Dao) Get(key *proto.BaseKey) (string, error) { val, ok := d.lru.Get(key) if !ok { - return "", errorx.NotKeyErr(key) + return "", errorx.NotKeyErr(key.Key) } strVal, ok := val.(structure.StringXInterface) @@ -51,7 +52,7 @@ func (d *Dao) Get(key string) (string, error) { return strVal.Get(), nil } -func (d *Dao) Add(key string, renewal int32) (string, error) { +func (d *Dao) Add(key *proto.BaseKey, renewal int32) (string, error) { value, lruOk := d.lru.Get(key) if !lruOk { val := stringx.NewStringSingle() @@ -75,7 +76,7 @@ func (d *Dao) Add(key string, renewal int32) (string, error) { return res, nil } -func (d *Dao) Reduce(key string, renewal int32) (string, error) { +func (d *Dao) Reduce(key *proto.BaseKey, renewal int32) (string, error) { value, lruOk := d.lru.Get(key) if !lruOk { val := stringx.NewStringSingle() @@ -99,7 +100,7 @@ func (d *Dao) Reduce(key string, renewal int32) (string, error) { return res, nil } -func (d *Dao) Setbit(key string, val bool, offer int32) error { +func (d *Dao) Setbit(key *proto.BaseKey, val bool, offer int32) error { value, lruOk := d.lru.Get(key) if !lruOk { valStr := stringx.NewStringSingle() @@ -119,10 +120,10 @@ func (d *Dao) Setbit(key string, val bool, offer int32) error { return nil } -func (d *Dao) GetBit(key string, offer int32) (bool, error) { +func (d *Dao) GetBit(key *proto.BaseKey, offer int32) (bool, error) { value, lruOk := d.lru.Get(key) if !lruOk { - return false, errorx.NotKeyErr(key) + return false, errorx.NotKeyErr(key.Key) } strVal, ok := value.(structure.StringXInterface) if !ok {