Documentation ¶
Index ¶
- Constants
- Variables
- func Del(k string) bool
- func DelByPtr(ptr unsafe.Pointer) bool
- func DeleteExpiredKeys()
- func DumpAllAOF()
- func Encode(value interface{}, isSimple bool) []byte
- func EvalAndRespond(cmds RedisCmds, c *Client)
- func ExtractTypeEncoding(obj *Obj) (uint8, uint8)
- func Put(k string, obj *Obj)
- func Shutdown()
- func UpdateDBStat(num int, metric string, value int)
- type Bloom
- type BloomOpts
- type ByIdleTime
- type Client
- type EvictionPool
- type Obj
- type PoolItem
- type QueueElement
- type QueueInt
- type QueueRef
- type RESPParser
- type RedisCmd
- type RedisCmds
- type StackElement
- type StackInt
- type StackRef
Constants ¶
const QueueIntMaxBuf int = 256
const StackIntMaxBuf int = 256
Variables ¶
var ErrQueueEmpty = errors.New("queue is empty")
var ErrStackEmpty = errors.New("stack is empty")
var KeyspaceStat [4]map[string]int
var OBJ_ENCODING_BF uint8 = 2 // 00000010
var OBJ_ENCODING_EMBSTR uint8 = 8
var OBJ_ENCODING_INT uint8 = 1
var OBJ_ENCODING_QINT uint8 = 0
var OBJ_ENCODING_QREF uint8 = 1
var OBJ_ENCODING_RAW uint8 = 0
var OBJ_ENCODING_STACKINT uint8 = 2
var OBJ_ENCODING_STACKREF uint8 = 3
var OBJ_TYPE_BITSET uint8 = 1 << 5 // 00100000
var OBJ_TYPE_BYTELIST uint8 = 1 << 4
var OBJ_TYPE_STRING uint8 = 0 << 4
var RESP_EMPTY_ARRAY []byte = []byte("*0\r\n")
var RESP_MINUS_1 []byte = []byte(":-1\r\n")
var RESP_MINUS_2 []byte = []byte(":-2\r\n")
var RESP_NIL []byte = []byte("$-1\r\n")
var RESP_OK []byte = []byte("+OK\r\n")
var RESP_ONE []byte = []byte(":1\r\n")
var RESP_QUEUED []byte = []byte("+QUEUED\r\n")
var RESP_ZERO []byte = []byte(":0\r\n")
Functions ¶
func DeleteExpiredKeys ¶
func DeleteExpiredKeys()
Deletes all the expired keys - the active way Sampling approach: https://redis.io/commands/expire/
func EvalAndRespond ¶
func ExtractTypeEncoding ¶
func UpdateDBStat ¶
Types ¶
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 (*Client) TxnDiscard ¶
func (c *Client) TxnDiscard()
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
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{} }
type QueueElement ¶
type QueueInt ¶
type QueueInt struct { Length int64 // contains filtered or unexported fields }
func NewQueueInt ¶
func NewQueueInt() *QueueInt
func (*QueueInt) Iterate ¶
Iterate inserts the integer `x` in the the QueueInt q through at max `n` elements. the function returns empty list for invalid `n`
type QueueRef ¶
type QueueRef struct {
// contains filtered or unexported fields
}
func NewQueueRef ¶
func NewQueueRef() *QueueRef
func (*QueueRef) Insert ¶
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
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 StackElement ¶
type StackInt ¶
type StackInt struct { Length int64 // contains filtered or unexported fields }
Represents a stack of integers
func (*StackInt) Iterate ¶
Iterate inserts the integer `x` in the the StackInt q through at max `n` elements. the function returns empty list for invalid `n`
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