database

package
v0.0.0-...-262ee3b Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NOEXPIRED = iota
	EXPIRED
	NOEXIST
)
View Source
const (
	SETNON = iota
	SETNX
	SETXX
)

Variables

View Source
var CmdTable = make(map[string]CmdFuc)
View Source
var PAGESIZE = 1024

Functions

func BitCount

func BitCount(src *[]byte, start, end int) int

func BitOp

func BitOp(op string, vals [][]byte) []byte

不要改变原来的vals[i] 不要append vals

func ExecAppend

func ExecAppend(engine *DBEngine, args [][]byte) parser.RespData

func ExecBitcount

func ExecBitcount(engine *DBEngine, args [][]byte) parser.RespData

func ExecBitop

func ExecBitop(engine *DBEngine, args [][]byte) parser.RespData

func ExecDecr

func ExecDecr(engine *DBEngine, args [][]byte) parser.RespData

func ExecDecrby

func ExecDecrby(engine *DBEngine, args [][]byte) parser.RespData

func ExecDel

func ExecDel(engine *DBEngine, args [][]byte) parser.RespData

func ExecEcho

func ExecEcho(engine *DBEngine, args [][]byte) parser.RespData

func ExecExists

func ExecExists(engine *DBEngine, args [][]byte) parser.RespData

func ExecExpire

func ExecExpire(engine *DBEngine, args [][]byte) parser.RespData

设置不成功返回0,成功返回1

func ExecExpireat

func ExecExpireat(engine *DBEngine, args [][]byte) parser.RespData

func ExecGet

func ExecGet(engine *DBEngine, args [][]byte) parser.RespData

func ExecGetbit

func ExecGetbit(engine *DBEngine, args [][]byte) parser.RespData

func ExecGetrange

func ExecGetrange(engine *DBEngine, args [][]byte) parser.RespData

func ExecGetset

func ExecGetset(engine *DBEngine, args [][]byte) parser.RespData

func ExecHdel

func ExecHdel(engine *DBEngine, args [][]byte) parser.RespData

func ExecHexists

func ExecHexists(engine *DBEngine, args [][]byte) parser.RespData

func ExecHget

func ExecHget(engine *DBEngine, args [][]byte) parser.RespData

func ExecHgetall

func ExecHgetall(engine *DBEngine, args [][]byte) parser.RespData

func ExecHincrby

func ExecHincrby(engine *DBEngine, args [][]byte) parser.RespData

func ExecHincrbyfloat

func ExecHincrbyfloat(engine *DBEngine, args [][]byte) parser.RespData

func ExecHkeys

func ExecHkeys(engine *DBEngine, args [][]byte) parser.RespData

func ExecHlen

func ExecHlen(engine *DBEngine, args [][]byte) parser.RespData

func ExecHmget

func ExecHmget(engine *DBEngine, args [][]byte) parser.RespData

func ExecHmset

func ExecHmset(engine *DBEngine, args [][]byte) parser.RespData

func ExecHset

func ExecHset(engine *DBEngine, args [][]byte) parser.RespData

func ExecHsetnx

func ExecHsetnx(engine *DBEngine, args [][]byte) parser.RespData

func ExecHvals

func ExecHvals(engine *DBEngine, args [][]byte) parser.RespData

func ExecIncr

func ExecIncr(engine *DBEngine, args [][]byte) parser.RespData

func ExecIncrby

func ExecIncrby(engine *DBEngine, args [][]byte) parser.RespData

func ExecIncrbyfloat

func ExecIncrbyfloat(engine *DBEngine, args [][]byte) parser.RespData

func ExecLindex

func ExecLindex(engine *DBEngine, args [][]byte) parser.RespData

func ExecLinsert

func ExecLinsert(engine *DBEngine, args [][]byte) parser.RespData

func ExecLlen

func ExecLlen(engine *DBEngine, args [][]byte) parser.RespData

func ExecLpop

func ExecLpop(engine *DBEngine, args [][]byte) parser.RespData

func ExecLpush

func ExecLpush(engine *DBEngine, args [][]byte) parser.RespData

func ExecLpushX

func ExecLpushX(engine *DBEngine, args [][]byte) parser.RespData

func ExecLrange

func ExecLrange(engine *DBEngine, args [][]byte) parser.RespData

func ExecLrem

func ExecLrem(engine *DBEngine, args [][]byte) parser.RespData

func ExecLset

func ExecLset(engine *DBEngine, args [][]byte) parser.RespData

func ExecLtrim

func ExecLtrim(engine *DBEngine, args [][]byte) parser.RespData

func ExecMget

func ExecMget(engine *DBEngine, args [][]byte) parser.RespData

func ExecMset

func ExecMset(engine *DBEngine, args [][]byte) parser.RespData

func ExecMsetnx

func ExecMsetnx(engine *DBEngine, args [][]byte) parser.RespData

func ExecPersist

func ExecPersist(engine *DBEngine, args [][]byte) parser.RespData

func ExecPing

func ExecPing(engine *DBEngine, args [][]byte) parser.RespData

func ExecRename

func ExecRename(engine *DBEngine, args [][]byte) parser.RespData

func ExecRenamenx

func ExecRenamenx(engine *DBEngine, args [][]byte) parser.RespData

func ExecRpop

func ExecRpop(engine *DBEngine, args [][]byte) parser.RespData

func ExecRpopLpush

func ExecRpopLpush(engine *DBEngine, args [][]byte) parser.RespData

func ExecRpush

func ExecRpush(engine *DBEngine, args [][]byte) parser.RespData

func ExecRpushX

func ExecRpushX(engine *DBEngine, args [][]byte) parser.RespData

func ExecSadd

func ExecSadd(engine *DBEngine, args [][]byte) parser.RespData

func ExecScard

func ExecScard(engine *DBEngine, args [][]byte) parser.RespData

func ExecSdiff

func ExecSdiff(engine *DBEngine, args [][]byte) parser.RespData

func ExecSdiffstore

func ExecSdiffstore(engine *DBEngine, args [][]byte) parser.RespData

func ExecSet

func ExecSet(engine *DBEngine, args [][]byte) parser.RespData

func ExecSetbit

func ExecSetbit(engine *DBEngine, args [][]byte) parser.RespData

func ExecSetex

func ExecSetex(engine *DBEngine, args [][]byte) parser.RespData

func ExecSetnx

func ExecSetnx(engine *DBEngine, args [][]byte) parser.RespData

func ExecSetrange

func ExecSetrange(engine *DBEngine, args [][]byte) parser.RespData

func ExecSinter

func ExecSinter(engine *DBEngine, args [][]byte) parser.RespData

func ExecSinterstore

func ExecSinterstore(engine *DBEngine, args [][]byte) parser.RespData

func ExecSismember

func ExecSismember(engine *DBEngine, args [][]byte) parser.RespData

func ExecSmembers

func ExecSmembers(engine *DBEngine, args [][]byte) parser.RespData

func ExecSmove

func ExecSmove(engine *DBEngine, args [][]byte) parser.RespData

func ExecSpop

func ExecSpop(engine *DBEngine, args [][]byte) parser.RespData

func ExecSrandmember

func ExecSrandmember(engine *DBEngine, args [][]byte) parser.RespData

func ExecSrem

func ExecSrem(engine *DBEngine, args [][]byte) parser.RespData

func ExecStrlen

func ExecStrlen(engine *DBEngine, args [][]byte) parser.RespData

func ExecSunion

func ExecSunion(engine *DBEngine, args [][]byte) parser.RespData

func ExecSunionStore

func ExecSunionStore(engine *DBEngine, args [][]byte) parser.RespData

func ExecTTL

func ExecTTL(engine *DBEngine, args [][]byte) parser.RespData

func ExecType

func ExecType(engine *DBEngine, args [][]byte) parser.RespData

func ForEachBit

func ForEachBit(src *[]byte, start, end int, f func(offset int, bitval byte) bool)

func GetBit

func GetBit(src *[]byte, offset int) int

func GetCompacity

func GetCompacity(num int) int

将参数变为二的幂,方便哈希后取模

func Grow

func Grow(src *[]byte, offset int)

func Inter

func Inter(sets []*Set) []string

func RegisterCmd

func RegisterCmd(cmd string, fun CmdFuc)

func SetBit

func SetBit(src *[]byte, offset int, bitVal int)

func Union

func Union(sets []*Set) []string

Types

type CmdFuc

type CmdFuc func(db *DBEngine, array [][]byte) parser.RespData

type ConcurrentMap

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

func NewConcurrentMap

func NewConcurrentMap(shardCount int) *ConcurrentMap

func (*ConcurrentMap) Del

func (conmap *ConcurrentMap) Del(key string)

func (*ConcurrentMap) DelWithLock

func (conmap *ConcurrentMap) DelWithLock(key string) bool

func (*ConcurrentMap) Get

func (conmap *ConcurrentMap) Get(key string) (any, bool)

func (*ConcurrentMap) GetWithLock

func (conmap *ConcurrentMap) GetWithLock(key string) (any, bool)

func (*ConcurrentMap) Set

func (conmap *ConcurrentMap) Set(key string, value any)

func (*ConcurrentMap) SetWithLock

func (conmap *ConcurrentMap) SetWithLock(key string, value any)

type DBEngine

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

func NewDBEngine

func NewDBEngine() *DBEngine

func (*DBEngine) CancelTTL

func (engine *DBEngine) CancelTTL(key string) bool

func (*DBEngine) ExecCmd

func (engine *DBEngine) ExecCmd(array [][]byte) parser.RespData

func (*DBEngine) SetTTL

func (engine *DBEngine) SetTTL(key string, delayTime time.Duration) bool

type HashTable

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

func NewHashTable

func NewHashTable() *HashTable

func (*HashTable) ALL

func (ht *HashTable) ALL() []string

func (*HashTable) Exist

func (ht *HashTable) Exist(key string) bool

func (*HashTable) Get

func (ht *HashTable) Get(key string) string

func (*HashTable) Keys

func (ht *HashTable) Keys() []string

func (*HashTable) Len

func (ht *HashTable) Len() int

func (*HashTable) Remove

func (ht *HashTable) Remove(key string) bool

func (*HashTable) Set

func (ht *HashTable) Set(key, value string) bool

func (*HashTable) Values

func (ht *HashTable) Values() []string

type ItemsLock

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

func NewItemsLock

func NewItemsLock(lockCount int) *ItemsLock

func (*ItemsLock) Lock

func (lock *ItemsLock) Lock(key string)

func (*ItemsLock) Locks

func (lock *ItemsLock) Locks(keys []string)

func (*ItemsLock) RLock

func (lock *ItemsLock) RLock(key string)

func (*ItemsLock) RLocks

func (lock *ItemsLock) RLocks(keys []string)

func (*ItemsLock) RUnLock

func (lock *ItemsLock) RUnLock(key string)

func (*ItemsLock) RUnLocks

func (lock *ItemsLock) RUnLocks(keys []string)

func (*ItemsLock) RWLocks

func (lock *ItemsLock) RWLocks(rkeys, wkeys []string)

func (*ItemsLock) RWUnLocks

func (lock *ItemsLock) RWUnLocks(rkeys, wkeys []string)

func (*ItemsLock) UnLock

func (lock *ItemsLock) UnLock(key string)

func (*ItemsLock) UnLocks

func (lock *ItemsLock) UnLocks(keys []string)

type QuickList

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

使用快速列表,拥有更好的range,find,add效率和紧凑的内存存储

func NewQuickList

func NewQuickList() *QuickList

创建有空头结点和空尾结点的链表

func (*QuickList) Find

func (ql *QuickList) Find(index int) *iterator

func (*QuickList) First

func (ql *QuickList) First() *iterator

func (*QuickList) ForEach

func (ql *QuickList) ForEach(f func(int, any) bool)

func (*QuickList) GetByIndex

func (ql *QuickList) GetByIndex(index int) []byte

func (*QuickList) Insert

func (ql *QuickList) Insert(index int, val any)

func (*QuickList) Len

func (ql *QuickList) Len() int

func (*QuickList) PushBack

func (ql *QuickList) PushBack(v any)

func (*QuickList) Range

func (ql *QuickList) Range(start, stop int) [][]byte

若下标值超出范围,则设为边界值 若start >= 列表长度,返回空列表

func (*QuickList) RemoveByCount

func (ql *QuickList) RemoveByCount(val []byte, count int) int

func (*QuickList) RemoveByIndex

func (ql *QuickList) RemoveByIndex(index int) []byte

支持负数下标

func (*QuickList) Set

func (ql *QuickList) Set(index int, val any) bool

type Set

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

func NewSet

func NewSet() *Set

func (*Set) Add

func (s *Set) Add(member string)

func (*Set) ForEach

func (s *Set) ForEach(f func(string) bool)

func (*Set) IsMember

func (s *Set) IsMember(member string) bool

func (*Set) Len

func (s *Set) Len() int

func (*Set) Members

func (s *Set) Members() []string

func (*Set) Pop

func (s *Set) Pop() string

func (*Set) RandMem

func (s *Set) RandMem(count int) []string

func (*Set) Remove

func (s *Set) Remove(member string) bool

type Shard

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

Jump to

Keyboard shortcuts

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