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

Method decodeString

cache/redis_cache.go:203–214  ·  view source on GitHub ↗
(bytes []byte)

Source from the content-addressed store, hash-verified

201}
202
203func (r *redisCache) decodeString(bytes []byte) (string, int, error) {
204 if len(bytes) < 4 {
205 return "", 0, &RedisCacheCorruptionError{}
206 }
207 b := bytes[:4]
208 n := uint32(b[3]) | (uint32(b[2]) << 8) | (uint32(b[1]) << 16) | (uint32(b[0]) << 24)
209 if len(bytes) < int(4+n) {
210 return "", 0, &RedisCacheCorruptionError{}
211 }
212 s := bytes[4 : 4+n]
213 return string(s), int(4 + n), nil
214}
215
216func (r *redisCache) encodeMetadata(contentMetadata *ContentMetadata) []byte {
217 cLength := contentMetadata.Length

Callers 2

decodeMetadataMethod · 0.95
TestStringFromToByteFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestStringFromToByteFunction · 0.64