예제 #1
0
// protoToItem converts a protocol buffer item to a Go struct.
func protoToItem(p *pb.MemcacheGetResponse_Item) *Item {
	return &Item{
		Key:   string(p.Key),
		Value: p.Value,
		Flags: p.GetFlags(),
		casID: p.GetCasId(),
	}
}
예제 #2
0
파일: memcache.go 프로젝트: yschu7/go_test
// protoToItem converts a protocol buffer item to a Go struct.
func protoToItem(p *pb.MemcacheGetResponse_Item) *Item {
	var expiration time.Duration
	sec := p.GetExpiresInSeconds()
	if sec > 0 && sec < secondsIn30Years {
		expiration = time.Duration(sec) * time.Second
	}
	return &Item{
		Key:        string(p.Key),
		Value:      p.Value,
		Flags:      p.GetFlags(),
		Expiration: expiration,
		casID:      p.GetCasId(),
	}
}