chore(service): updater dao service

This commit is contained in:
bandl 2021-11-02 20:35:45 +08:00
parent 4ca09febb4
commit 7d9081ce8e
3 changed files with 100 additions and 16 deletions

95
storage/dao/dao.gen.go Normal file
View File

@ -0,0 +1,95 @@
// Code generated by gen-struct. DO NOT EDIT.
// make gen-service generated
package dao
import (
"gitee.com/wheat-os/wheatCache/pkg/errorx"
"gitee.com/wheat-os/wheatCache/pkg/lru"
"gitee.com/wheat-os/wheatCache/pkg/proto"
protobuf "google.golang.org/protobuf/proto"
)
type Dao struct {
lru lru.CacheInterface
}
func NewDao(lru lru.CacheInterface) Interface {
return &Dao{
lru: lru,
}
}
// 执行 msg
func (d *Dao) ExecMessage(message protobuf.Message) error {
switch req := message.(type) {
case *proto.LIndexRequest:
_, err := d.LIndex(req.Key, req.Index)
return err
case *proto.LLenRequest:
_, err := d.LLen(req.Key)
return err
case *proto.LPopRequest:
_, err := d.LPop(req.Key, req.Count)
return err
case *proto.LPushRequest:
_, err := d.LPush(req.Key, req.Values)
return err
case *proto.LPushXRequest:
_, err := d.LPushX(req.Key, req.Values)
return err
case *proto.LRangeRequest:
_, err := d.LRange(req.Key, req.Start, req.End)
return err
case *proto.LRemRequest:
_, err := d.LRem(req.Key, req.Count, req.Value)
return err
case *proto.LSetRequest:
_, err := d.LSet(req.Key, req.Index, req.Value)
return err
case *proto.RPopRequest:
_, err := d.RPop(req.Key, req.Count)
return err
case *proto.LTrimRequest:
_, err := d.LTrim(req.Key, req.Start, req.End)
return err
case *proto.RPushRequest:
_, err := d.RPush(req.Key, req.Values)
return err
case *proto.RPushXRequest:
_, err := d.RPushX(req.Key, req.Values)
return err
case *proto.SetRequest:
_, err := d.Set(req.Key, req.Val)
return err
case *proto.GetRequest:
_, err := d.Get(req.Key)
return err
case *proto.AddRequest:
_, err := d.Add(req.Key, req.Renewal)
return err
case *proto.ReduceRequest:
_, err := d.Reduce(req.Key, req.Renewal)
return err
case *proto.SetnxRequest:
_, err := d.Setnx(req.Key, req.Val)
return err
case *proto.SetBitRequest:
_, err := d.SetBit(req.Key, req.Val, req.Offer)
return err
case *proto.GetBitRequest:
_, err := d.GetBit(req.Key, req.Offer)
return err
case *proto.GetRangeRequest:
_, err := d.GetRange(req.Key, req.Start, req.End)
return err
case *proto.GetSetRequest:
_, err := d.GetSet(req.Key, req.Val)
return err
case *proto.StrLenRequest:
_, err := d.StrLen(req.Key)
return err
default:
return errorx.New("The type that is not registered exec err")
}
}

View File

@ -1,15 +0,0 @@
package dao
import (
"gitee.com/wheat-os/wheatCache/pkg/lru"
)
type Dao struct {
lru lru.CacheInterface
}
func NewDao(lru lru.CacheInterface) Interface {
return &Dao{
lru: lru,
}
}

View File

@ -3,7 +3,10 @@
package dao
import "gitee.com/wheat-os/wheatCache/pkg/proto"
import (
"gitee.com/wheat-os/wheatCache/pkg/proto"
protobuf "google.golang.org/protobuf/proto"
)
type Interface interface {
LIndex(*proto.BaseKey, int32) (*proto.LIndexResponse, error)
@ -28,4 +31,5 @@ type Interface interface {
GetRange(*proto.BaseKey, int32, int32) (*proto.GetRangeResponse, error)
GetSet(*proto.BaseKey, string) (*proto.GetSetResponse, error)
StrLen(*proto.BaseKey) (*proto.StrLenResponse, error)
ExecMessage(message protobuf.Message) error
}