wheat-cache/storage/service/single_service.gen.go

880 lines
21 KiB
Go
Raw Normal View History

// Code generated by gen-struct. DO NOT EDIT.
// make gen-service generated
package service
import (
context "context"
2021-11-02 14:45:08 +08:00
"gitee.com/wheat-os/wheatCache/pkg/event"
"gitee.com/wheat-os/wheatCache/pkg/lru"
"gitee.com/wheat-os/wheatCache/pkg/proto"
)
func (s *singleService) LIndex(
ctx context.Context,
req *proto.LIndexRequest,
) (*proto.LIndexResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LIndex(req.Key, req.Index)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LIndex", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LIndexResponse), nil
}
func (s *singleService) LLen(
ctx context.Context,
req *proto.LLenRequest,
) (*proto.LLenResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LLen(req.Key)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LLen", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LLenResponse), nil
}
func (s *singleService) LPop(
ctx context.Context,
req *proto.LPopRequest,
) (*proto.LPopResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LPop(req.Key, req.Count)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LPop", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LPopResponse), nil
}
func (s *singleService) LPush(
ctx context.Context,
req *proto.LPushRequest,
) (*proto.LPushResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LPush(req.Key, req.Values)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LPush", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LPushResponse), nil
}
func (s *singleService) LPushX(
ctx context.Context,
req *proto.LPushXRequest,
) (*proto.LPushXResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LPushX(req.Key, req.Values)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LPushX", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LPushXResponse), nil
}
func (s *singleService) LRange(
ctx context.Context,
req *proto.LRangeRequest,
) (*proto.LRangeResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LRange(req.Key, req.Start, req.End)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LRange", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LRangeResponse), nil
}
func (s *singleService) LRem(
ctx context.Context,
req *proto.LRemRequest,
) (*proto.LRemResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LRem(req.Key, req.Count, req.Value)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LRem", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LRemResponse), nil
}
func (s *singleService) LSet(
ctx context.Context,
req *proto.LSetRequest,
) (*proto.LSetResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LSet(req.Key, req.Index, req.Value)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LSet", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LSetResponse), nil
}
func (s *singleService) RPop(
ctx context.Context,
req *proto.RPopRequest,
) (*proto.RPopResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.RPop(req.Key, req.Count)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("RPop", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.RPopResponse), nil
}
func (s *singleService) LTrim(
ctx context.Context,
req *proto.LTrimRequest,
) (*proto.LTrimResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.LTrim(req.Key, req.Start, req.End)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("LTrim", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.LTrimResponse), nil
}
func (s *singleService) RPush(
ctx context.Context,
req *proto.RPushRequest,
) (*proto.RPushResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.RPush(req.Key, req.Values)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("RPush", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.RPushResponse), nil
}
func (s *singleService) RPushX(
ctx context.Context,
req *proto.RPushXRequest,
) (*proto.RPushXResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.RPushX(req.Key, req.Values)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("RPushX", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.RPushXResponse), nil
}
2021-11-04 20:36:42 +08:00
func (s *singleService) HDel(
ctx context.Context,
req *proto.HDelRequest,
) (*proto.HDelResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HDel(req.Key, req.HKeys)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HDel", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HDelResponse), nil
}
func (s *singleService) HExists(
ctx context.Context,
req *proto.HExistsRequest,
) (*proto.HExistsResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HExists(req.Key, req.HKey)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HExists", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HExistsResponse), nil
}
func (s *singleService) HGet(
ctx context.Context,
req *proto.HGetRequest,
) (*proto.HGetResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HGet(req.Key, req.HKeys)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HGet", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HGetResponse), nil
}
func (s *singleService) HGetAll(
ctx context.Context,
req *proto.HGetAllRequest,
) (*proto.HGetAllResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HGetAll(req.Key)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HGetAll", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HGetAllResponse), nil
}
func (s *singleService) HIncrBy(
ctx context.Context,
req *proto.HIncrByRequest,
) (*proto.HIncrByResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-05 20:43:56 +08:00
resp, err := s.dao.HIncrBy(req.Key, req.HKeys, req.Renewal)
2021-11-04 20:36:42 +08:00
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HIncrBy", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HIncrByResponse), nil
}
func (s *singleService) HKeys(
ctx context.Context,
req *proto.HKeysRequest,
) (*proto.HKeysResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HKeys(req.Key)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HKeys", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HKeysResponse), nil
}
func (s *singleService) HLen(
ctx context.Context,
req *proto.HLenRequest,
) (*proto.HLenResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HLen(req.Key)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HLen", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HLenResponse), nil
}
func (s *singleService) HSet(
ctx context.Context,
req *proto.HSetRequest,
) (*proto.HSetResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HSet(req.Key, req.Items)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HSet", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HSetResponse), nil
}
func (s *singleService) HSetX(
ctx context.Context,
req *proto.HSetXRequest,
) (*proto.HSetXResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HSetX(req.Key, req.Items)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HSetX", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HSetXResponse), nil
}
func (s *singleService) Set(
ctx context.Context,
req *proto.SetRequest,
) (*proto.SetResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.Set(req.Key, req.Val)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("Set", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.SetResponse), nil
}
func (s *singleService) Get(
ctx context.Context,
req *proto.GetRequest,
) (*proto.GetResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.Get(req.Key)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("Get", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.GetResponse), nil
}
func (s *singleService) Add(
ctx context.Context,
req *proto.AddRequest,
) (*proto.AddResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.Add(req.Key, req.Renewal)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("Add", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.AddResponse), nil
}
func (s *singleService) Reduce(
ctx context.Context,
req *proto.ReduceRequest,
) (*proto.ReduceResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.Reduce(req.Key, req.Renewal)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("Reduce", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.ReduceResponse), nil
}
func (s *singleService) Setnx(
ctx context.Context,
req *proto.SetnxRequest,
) (*proto.SetnxResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.Setnx(req.Key, req.Val)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("Setnx", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.SetnxResponse), nil
}
func (s *singleService) SetBit(
ctx context.Context,
req *proto.SetBitRequest,
) (*proto.SetBitResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.SetBit(req.Key, req.Val, req.Offer)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("SetBit", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.SetBitResponse), nil
}
func (s *singleService) GetBit(
ctx context.Context,
req *proto.GetBitRequest,
) (*proto.GetBitResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.GetBit(req.Key, req.Offer)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("GetBit", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.GetBitResponse), nil
}
func (s *singleService) GetRange(
ctx context.Context,
req *proto.GetRangeRequest,
) (*proto.GetRangeResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.GetRange(req.Key, req.Start, req.End)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("GetRange", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.GetRangeResponse), nil
}
func (s *singleService) GetSet(
ctx context.Context,
req *proto.GetSetRequest,
) (*proto.GetSetResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.GetSet(req.Key, req.Val)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("GetSet", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.GetSetResponse), nil
}
func (s *singleService) StrLen(
ctx context.Context,
req *proto.StrLenRequest,
) (*proto.StrLenResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.StrLen(req.Key)
if err != nil {
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("StrLen", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.StrLenResponse), nil
}