blob

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SizePowerSize = 1 // byte
	StatusSize    = 1 // byte
	KeyLenSize    = 2 // bytes
	ValLenSize    = 4 // bytes
	ExpireSize    = 4 // bytes

	HeaderSize = SizePowerSize + StatusSize + KeyLenSize + ValLenSize + ExpireSize // bytes

	StatusOffset = SizePowerSize
)
View Source
const (
	StatusOK      = 212
	StatusDeleted = 106
)

Variables

This section is empty.

Functions

func NextNumberOfPowerOfTwo

func NextNumberOfPowerOfTwo[V int | int32 | int64](value V) (byte, V)

func NextPowerOfTwo

func NextPowerOfTwo[V int | int32 | int64](value V) V

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

func NewBuffer

func NewBuffer(size int) *Buffer

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

func (*Buffer) WriteHeader

func (b *Buffer) WriteHeader(h Header)

func (*Buffer) WriteKey

func (b *Buffer) WriteKey(key []byte)

func (*Buffer) WriteValue

func (b *Buffer) WriteValue(val []byte)
type Header struct {
	SizePower byte
	Status    Status
	KeyLen    uint16
	ValLen    uint32
	Expire    uint32
}

func UnmarshalHeader

func UnmarshalHeader(buffer []byte) Header

func (Header) IsExpired

func (h Header) IsExpired(now time.Time) bool

func (Header) Size

func (h Header) Size() int

type KVE

type KVE struct {
	Key    []byte
	Value  []byte
	Expire uint32
}

KVE stands for Key Value Expire

func Unmarshal

func Unmarshal(buffer []byte) KVE

func UnmarshalBody

func UnmarshalBody(buffer []byte, header Header) KVE

func (KVE) IsExpired

func (kve KVE) IsExpired(now time.Time) bool

func (KVE) Marshal

func (kve KVE) Marshal() (_ []byte, nextPowerOfTwo int)

type Status

type Status byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL