Exemplo n.º 1
0
func add(req *proto.MCRequest, cache *cache.Cache) *proto.MCResponse {
	res := proto.NewResStatus(req.Opcode, proto.STORED)

	if err := cache.Add(req.Key, req.Value,
		time.Duration(req.Expires)*time.Second); err != nil {
		res = proto.NewResStatus(req.Opcode, proto.NOT_STORED)
	}
	return res
}