func replace(req *proto.MCRequest, cache *cache.Cache) *proto.MCResponse { res := proto.NewResStatus(req.Opcode, proto.STORED) if err := cache.Replace(req.Key, req.Value, time.Duration(req.Expires)*time.Second); err != nil { res = proto.NewResStatus(req.Opcode, proto.NOT_STORED) } return res }
func delete(req *proto.MCRequest, cache *cache.Cache) *proto.MCResponse { cache.Delete(req.Key) res := proto.NewResStatus(req.Opcode, proto.DELETED) return res }
func set(req *proto.MCRequest, cache *cache.Cache) *proto.MCResponse { cache.Set(req.Key, req.Value, time.Duration(req.Expires)*time.Second) res := proto.NewResStatus(req.Opcode, proto.SUCCESS) return res }