forked from p93542168/wheat-cache
chore(service): update service
This commit is contained in:
parent
3b61f55fe3
commit
72add38cee
|
@ -15,7 +15,12 @@ func (s *singleService) LIndex(
|
|||
req *proto.LIndexRequest,
|
||||
) (*proto.LIndexResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LIndex(req.Key, req.Index)
|
||||
resp, err := s.dao.LIndex(req.Key, req.Index)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LIndex", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -36,7 +41,12 @@ func (s *singleService) LLen(
|
|||
req *proto.LLenRequest,
|
||||
) (*proto.LLenResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LLen(req.Key)
|
||||
resp, err := s.dao.LLen(req.Key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LLen", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -57,7 +67,12 @@ func (s *singleService) LPop(
|
|||
req *proto.LPopRequest,
|
||||
) (*proto.LPopResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LPop(req.Key, req.Count)
|
||||
resp, err := s.dao.LPop(req.Key, req.Count)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LPop", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -78,7 +93,12 @@ func (s *singleService) LPush(
|
|||
req *proto.LPushRequest,
|
||||
) (*proto.LPushResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LPush(req.Key, req.Values)
|
||||
resp, err := s.dao.LPush(req.Key, req.Values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LPush", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -99,7 +119,12 @@ func (s *singleService) LPushX(
|
|||
req *proto.LPushXRequest,
|
||||
) (*proto.LPushXResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LPushX(req.Key, req.Values)
|
||||
resp, err := s.dao.LPushX(req.Key, req.Values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LPushX", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -120,7 +145,12 @@ func (s *singleService) LRange(
|
|||
req *proto.LRangeRequest,
|
||||
) (*proto.LRangeResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LRange(req.Key, req.Start, req.End)
|
||||
resp, err := s.dao.LRange(req.Key, req.Start, req.End)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LRange", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -141,7 +171,12 @@ func (s *singleService) LRem(
|
|||
req *proto.LRemRequest,
|
||||
) (*proto.LRemResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LRem(req.Key, req.Count, req.Value)
|
||||
resp, err := s.dao.LRem(req.Key, req.Count, req.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LRem", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -162,7 +197,12 @@ func (s *singleService) LSet(
|
|||
req *proto.LSetRequest,
|
||||
) (*proto.LSetResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LSet(req.Key, req.Index, req.Value)
|
||||
resp, err := s.dao.LSet(req.Key, req.Index, req.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LSet", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -183,7 +223,12 @@ func (s *singleService) RPop(
|
|||
req *proto.RPopRequest,
|
||||
) (*proto.RPopResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.RPop(req.Key, req.Count)
|
||||
resp, err := s.dao.RPop(req.Key, req.Count)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("RPop", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -204,7 +249,12 @@ func (s *singleService) LTrim(
|
|||
req *proto.LTrimRequest,
|
||||
) (*proto.LTrimResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.LTrim(req.Key, req.Start, req.End)
|
||||
resp, err := s.dao.LTrim(req.Key, req.Start, req.End)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("LTrim", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -225,7 +275,12 @@ func (s *singleService) RPush(
|
|||
req *proto.RPushRequest,
|
||||
) (*proto.RPushResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.RPush(req.Key, req.Values)
|
||||
resp, err := s.dao.RPush(req.Key, req.Values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("RPush", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -246,7 +301,12 @@ func (s *singleService) RPushX(
|
|||
req *proto.RPushXRequest,
|
||||
) (*proto.RPushXResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.RPushX(req.Key, req.Values)
|
||||
resp, err := s.dao.RPushX(req.Key, req.Values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("RPushX", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -267,7 +327,12 @@ func (s *singleService) Set(
|
|||
req *proto.SetRequest,
|
||||
) (*proto.SetResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.Set(req.Key, req.Val)
|
||||
resp, err := s.dao.Set(req.Key, req.Val)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("Set", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -288,7 +353,12 @@ func (s *singleService) Get(
|
|||
req *proto.GetRequest,
|
||||
) (*proto.GetResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.Get(req.Key)
|
||||
resp, err := s.dao.Get(req.Key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("Get", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -309,7 +379,12 @@ func (s *singleService) Add(
|
|||
req *proto.AddRequest,
|
||||
) (*proto.AddResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.Add(req.Key, req.Renewal)
|
||||
resp, err := s.dao.Add(req.Key, req.Renewal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("Add", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -330,7 +405,12 @@ func (s *singleService) Reduce(
|
|||
req *proto.ReduceRequest,
|
||||
) (*proto.ReduceResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.Reduce(req.Key, req.Renewal)
|
||||
resp, err := s.dao.Reduce(req.Key, req.Renewal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("Reduce", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -351,7 +431,12 @@ func (s *singleService) Setnx(
|
|||
req *proto.SetnxRequest,
|
||||
) (*proto.SetnxResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.Setnx(req.Key, req.Val)
|
||||
resp, err := s.dao.Setnx(req.Key, req.Val)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("Setnx", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -372,7 +457,12 @@ func (s *singleService) SetBit(
|
|||
req *proto.SetBitRequest,
|
||||
) (*proto.SetBitResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.SetBit(req.Key, req.Val, req.Offer)
|
||||
resp, err := s.dao.SetBit(req.Key, req.Val, req.Offer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("SetBit", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -393,7 +483,12 @@ func (s *singleService) GetBit(
|
|||
req *proto.GetBitRequest,
|
||||
) (*proto.GetBitResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.GetBit(req.Key, req.Offer)
|
||||
resp, err := s.dao.GetBit(req.Key, req.Offer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("GetBit", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -414,7 +509,12 @@ func (s *singleService) GetRange(
|
|||
req *proto.GetRangeRequest,
|
||||
) (*proto.GetRangeResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.GetRange(req.Key, req.Start, req.End)
|
||||
resp, err := s.dao.GetRange(req.Key, req.Start, req.End)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("GetRange", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -435,7 +535,12 @@ func (s *singleService) GetSet(
|
|||
req *proto.GetSetRequest,
|
||||
) (*proto.GetSetResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.GetSet(req.Key, req.Val)
|
||||
resp, err := s.dao.GetSet(req.Key, req.Val)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("GetSet", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
@ -456,7 +561,12 @@ func (s *singleService) StrLen(
|
|||
req *proto.StrLenRequest,
|
||||
) (*proto.StrLenResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.StrLen(req.Key)
|
||||
resp, err := s.dao.StrLen(req.Key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("StrLen", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
|
|
@ -16,7 +16,12 @@ func (s *singleService) {{key.method}}(
|
|||
req *proto.{{key.method}}Request,
|
||||
) (*proto.{{key.method}}Response, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.{{key.method}}({% for opt in key.option %}req.{{opt[0]}}, {% endfor %})
|
||||
resp, err := s.dao.{{key.method}}({% for opt in key.option %}req.{{opt[0]}}, {% endfor %})
|
||||
if err != nil{
|
||||
return nil, err
|
||||
}
|
||||
s.aof.SendRequest("{{key.method}}", req)
|
||||
return resp, nil
|
||||
})
|
||||
|
||||
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
|
||||
|
|
Loading…
Reference in New Issue