structs.go
func encodeEntry(e *Entry, buf *bytes.Buffer) (int, error) {
	h := header{
		klen:      uint32(len(e.Key)),
		vlen:      uint32(len(e.Value)),
		expiresAt: e.ExpiresAt,
		meta:      e.meta,
		userMeta:  e.UserMeta,
	}

	var headerEnc [headerBufSize]byte
	h.Encode(headerEnc[:])

	hash := crc32.New(y.CastagnoliCrcTable)

	buf.Write(headerEnc[:])
	hash.Write(headerEnc[:])

	buf.Write(e.Key)
	hash.Write(e.Key)

	buf.Write(e.Value)
	hash.Write(e.Value)

	var crcBuf [crc32.Size]byte
	binary.BigEndian.PutUint32(crcBuf[:], hash.Sum32())
	buf.Write(crcBuf[:])

	return len(headerEnc) + len(e.Key) + len(e.Value) + len(crcBuf), nil
}
func encodeEntry(e *Entry, buf *bytes.Buffer) (int, error) {
	h := header{
		klen:      uint32(len(e.Key)),
		vlen:      uint32(len(e.Value)),
		expiresAt: e.ExpiresAt,
		meta:      e.meta,
		userMeta:  e.UserMeta,
	}

	var headerEnc [headerBufSize]byte
	h.Encode(headerEnc[:])

	hash := crc32.New(y.CastagnoliCrcTable)

	buf.Write(headerEnc[:])
	hash.Write(headerEnc[:])

	buf.Write(e.Key)
	hash.Write(e.Key)

	buf.Write(e.Value)
	hash.Write(e.Value)

	var crcBuf [crc32.Size]byte
	binary.BigEndian.PutUint32(crcBuf[:], hash.Sum32())
	buf.Write(crcBuf[:])

	return len(headerEnc) + len(e.Key) + len(e.Value) + len(crcBuf), nil
}
func encodeEntry ( e * Entry , buf * bytes . Buffer ) ( int , error ) { h := header { klen : uint32 ( len ( e . Key ) ) , vlen : uint32 ( len ( e . Value ) ) , expiresAt : e . ExpiresAt , meta : e . meta , userMeta : e . UserMeta , } var headerEnc [ headerBufSize ] byte h . Encode ( headerEnc [ : ] ) hash := crc32 . New ( y . CastagnoliCrcTable ) buf . Write ( headerEnc [ : ] ) hash . Write ( headerEnc [ : ] ) buf . Write ( e . Key ) hash . Write ( e . Key ) buf . Write ( e . Value ) hash . Write ( e . Value ) var crcBuf [ crc32 . Size ] byte binary . BigEndian . PutUint32 ( crcBuf [ : ] , hash . Sum32 ( ) ) buf . Write ( crcBuf [ : ] ) return len ( headerEnc ) + len ( e . Key ) + len ( e . Value ) + len ( crcBuf ) , nil }
// Encodes e to buf. Returns number of bytes written.
Encodes e to buf . Returns number of bytes written .