core

package
v0.0.0-...-9473d91 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const QueueIntMaxBuf int = 256
View Source
const StackIntMaxBuf int = 256

Variables

View Source
var ErrQueueEmpty = errors.New("queue is empty")
View Source
var ErrStackEmpty = errors.New("stack is empty")
View Source
var KeyspaceStat [4]map[string]int
View Source
var OBJ_ENCODING_BF uint8 = 2 // 00000010
View Source
var OBJ_ENCODING_EMBSTR uint8 = 8
View Source
var OBJ_ENCODING_INT uint8 = 1
View Source
var OBJ_ENCODING_QINT uint8 = 0
View Source
var OBJ_ENCODING_QREF uint8 = 1
View Source
var OBJ_ENCODING_RAW uint8 = 0
View Source
var OBJ_ENCODING_STACKINT uint8 = 2
View Source
var OBJ_ENCODING_STACKREF uint8 = 3
View Source
var OBJ_TYPE_BITSET uint8 = 1 << 5 // 00100000
View Source
var OBJ_TYPE_BYTELIST uint8 = 1 << 4
View Source
var OBJ_TYPE_STRING uint8 = 0 << 4
View Source
var RESP_EMPTY_ARRAY []byte = []byte("*0\r\n")
View Source
var RESP_MINUS_1 []byte = []byte(":-1\r\n")
View Source
var RESP_MINUS_2 []byte = []byte(":-2\r\n")
View Source
var RESP_NIL []byte = []byte("$-1\r\n")
View Source
var RESP_OK []byte = []byte("+OK\r\n")
View Source
var RESP_ONE []byte = []byte(":1\r\n")
View Source
var RESP_QUEUED []byte = []byte("+QUEUED\r\n")
View Source
var RESP_ZERO []byte = []byte(":0\r\n")

Functions

func Del

func Del(k string) bool

func DelByPtr

func DelByPtr(ptr unsafe.Pointer) bool

func DeleteExpiredKeys

func DeleteExpiredKeys()

Deletes all the expired keys - the active way Sampling approach: https://redis.io/commands/expire/

func DumpAllAOF

func DumpAllAOF()

TODO: To to new and switch

func Encode

func Encode(value interface{}, isSimple bool) []byte

func EvalAndRespond

func EvalAndRespond(cmds RedisCmds, c *Client)

func ExtractTypeEncoding

func ExtractTypeEncoding(obj *Obj) (uint8, uint8)

func Put

func Put(k string, obj *Obj)

func Shutdown

func Shutdown()

func UpdateDBStat

func UpdateDBStat(num int, metric string, value int)

Types

type Bloom

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

type BloomOpts

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

type ByIdleTime

type ByIdleTime []*PoolItem

func (ByIdleTime) Len

func (a ByIdleTime) Len() int

func (ByIdleTime) Less

func (a ByIdleTime) Less(i, j int) bool

func (ByIdleTime) Swap

func (a ByIdleTime) Swap(i, j int)

type Client

type Client struct {
	io.ReadWriter
	Fd int
	// contains filtered or unexported fields
}

func NewClient

func NewClient(fd int) *Client

func (Client) Read

func (c Client) Read(b []byte) (int, error)

func (*Client) TxnBegin

func (c *Client) TxnBegin()

func (*Client) TxnDiscard

func (c *Client) TxnDiscard()

func (*Client) TxnExec

func (c *Client) TxnExec() []byte

func (*Client) TxnQueue

func (c *Client) TxnQueue(cmd *RedisCmd)

func (Client) Write

func (c Client) Write(b []byte) (int, error)

type EvictionPool

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

TODO: When last accessed at of object changes update the poolItem correponding to that

func (*EvictionPool) Pop

func (pq *EvictionPool) Pop() *PoolItem

func (*EvictionPool) Push

func (pq *EvictionPool) Push(key unsafe.Pointer, lastAccessedAt uint32)

TODO: Make the implementation efficient to not need repeated sorting

type Obj

type Obj struct {
	TypeEncoding uint8
	// Redis allots 24 bits to these bits, but we will use 32 bits because
	// golang does not support bitfields and we need not make this super-complicated
	// by merging TypeEncoding + LastAccessedAt in one 32 bit integer.
	// But nonetheless, we can benchmark and see how that fares.
	// For now, we continue with 32 bit integer to store the LastAccessedAt
	LastAccessedAt uint32
	Value          interface{}
}

func Get

func Get(k string) *Obj

func NewObj

func NewObj(value interface{}, expDurationMs int64, oType uint8, oEnc uint8) *Obj

type PoolItem

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

type QueueElement

type QueueElement struct {
	Key string
	Obj *Obj
}

type QueueInt

type QueueInt struct {
	Length int64
	// contains filtered or unexported fields
}

func NewQueueInt

func NewQueueInt() *QueueInt

func (*QueueInt) Insert

func (q *QueueInt) Insert(x int64)

Insert inserts the integer `x` in the the QueueInt q.

func (*QueueInt) Iterate

func (q *QueueInt) Iterate(n int) []int64

Iterate inserts the integer `x` in the the QueueInt q through at max `n` elements. the function returns empty list for invalid `n`

func (*QueueInt) Remove

func (q *QueueInt) Remove() (int64, error)

Remove removes the integer from the queue q.

func (*QueueInt) Size

func (q *QueueInt) Size() int64

type QueueRef

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

func NewQueueRef

func NewQueueRef() *QueueRef

func (*QueueRef) Insert

func (q *QueueRef) Insert(key string) bool

Insert inserts reference of the key in the QueueRef q. returns false if key does not exist

func (*QueueRef) Iterate

func (q *QueueRef) Iterate(n int) []*QueueElement

Iterate iterates through the QueueRef it also filters out the keys that are expired

func (*QueueRef) Remove

func (q *QueueRef) Remove() (*QueueElement, error)

Remove removes the reference from the queue q. returns nil if key does not exist in the store any more if the expired key is popped from the queue, we continue to pop until until we find one non-expired key TODO: test for expired keys

func (*QueueRef) Size

func (q *QueueRef) Size() int64

type RESPParser

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

func NewRESPParser

func NewRESPParser(c io.ReadWriter) *RESPParser

func NewRESPParserWithBytes

func NewRESPParserWithBytes(c io.ReadWriter, initBytes []byte) *RESPParser

func (*RESPParser) DecodeMultiple

func (rp *RESPParser) DecodeMultiple() ([]interface{}, error)

func (*RESPParser) DecodeOne

func (rp *RESPParser) DecodeOne() (interface{}, error)

type RedisCmd

type RedisCmd struct {
	Cmd  string
	Args []string
}

type RedisCmds

type RedisCmds []*RedisCmd

type StackElement

type StackElement struct {
	Key string
	Obj *Obj
}

type StackInt

type StackInt struct {
	Length int64
	// contains filtered or unexported fields
}

Represents a stack of integers

func NewStackInt

func NewStackInt() *StackInt

Returns a pointer to a newly allocated StackInt.

func (*StackInt) Iterate

func (s *StackInt) Iterate(n int) []int64

Iterate inserts the integer `x` in the the StackInt q through at max `n` elements. the function returns empty list for invalid `n`

func (*StackInt) Pop

func (s *StackInt) Pop() (int64, error)

Pop Pops an integer from the Stack s.

func (*StackInt) Push

func (s *StackInt) Push(x int64)

Push pushes the integer `x` in the the StackInt s.

func (*StackInt) Size

func (s *StackInt) Size() int64

type StackRef

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

func NewStackRef

func NewStackRef() *StackRef

func (*StackRef) Iterate

func (s *StackRef) Iterate(n int) []*StackElement

Iterate iterates through the StackRef it also filters out the keys that are expired

func (*StackRef) Pop

func (s *StackRef) Pop() (*StackElement, error)

Pop pops the reference from the stack s. returns nil if key does not exist in the store any more if the expired key is popped from the stack, we continue to pop until until we find one non-expired key TODO: test for expired keys

func (*StackRef) Push

func (s *StackRef) Push(key string) bool

Push pushes reference of the key in the StackRef s. returns false if key does not exist

func (*StackRef) Size

func (s *StackRef) Size() int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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