forked from p93542168/wheat-cache
96 lines
2.3 KiB
Go
96 lines
2.3 KiB
Go
// 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")
|
|
}
|
|
}
|