MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / encodeMetadata

Method encodeMetadata

cache/redis_cache.go:216–225  ·  view source on GitHub ↗
(contentMetadata *ContentMetadata)

Source from the content-addressed store, hash-verified

214}
215
216func (r *redisCache) encodeMetadata(contentMetadata *ContentMetadata) []byte {
217 cLength := contentMetadata.Length
218 cType := r.encodeString(contentMetadata.Type)
219 cEncoding := r.encodeString(contentMetadata.Encoding)
220 b := make([]byte, 0, len(cEncoding)+len(cType)+8)
221 b = append(b, byte(cLength>>56), byte(cLength>>48), byte(cLength>>40), byte(cLength>>32), byte(cLength>>24), byte(cLength>>16), byte(cLength>>8), byte(cLength))
222 b = append(b, cType...)
223 b = append(b, cEncoding...)
224 return b
225}
226
227func (r *redisCache) decodeMetadata(b []byte) (*ContentMetadata, int, error) {
228 if len(b) < 8 {

Callers 2

PutMethod · 0.95
TestMetadataFromToByteFunction · 0.80

Calls 1

encodeStringMethod · 0.95

Tested by 1

TestMetadataFromToByteFunction · 0.64