MCPcopy Create free account
hub / github.com/allegro/bigcache / wrapEntry

Function wrapEntry

encoding.go:14–30  ·  view source on GitHub ↗
(timestamp uint64, hash uint64, key string, entry []byte, buffer *[]byte)

Source from the content-addressed store, hash-verified

12)
13
14func wrapEntry(timestamp uint64, hash uint64, key string, entry []byte, buffer *[]byte) []byte {
15 keyLength := len(key)
16 blobLength := len(entry) + headersSizeInBytes + keyLength
17
18 if blobLength > len(*buffer) {
19 *buffer = make([]byte, blobLength)
20 }
21 blob := *buffer
22
23 binary.LittleEndian.PutUint64(blob, timestamp)
24 binary.LittleEndian.PutUint64(blob[timestampSizeInBytes:], hash)
25 binary.LittleEndian.PutUint16(blob[timestampSizeInBytes+hashSizeInBytes:], uint16(keyLength))
26 copy(blob[headersSizeInBytes:], key)
27 copy(blob[headersSizeInBytes+keyLength:], entry)
28
29 return blob[:blobLength]
30}
31
32func appendToWrappedEntry(timestamp uint64, wrappedEntry []byte, entry []byte, buffer *[]byte) []byte {
33 blobLength := len(wrappedEntry) + len(entry)

Callers 4

setMethod · 0.85
addNewWithoutLockMethod · 0.85
TestEncodeDecodeFunction · 0.85
TestAllocateBiggerBufferFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestEncodeDecodeFunction · 0.68
TestAllocateBiggerBufferFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…