list

package
v0.0.0-...-61d8e7e Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrListNotFound is returned when the list not found.
	ErrListNotFound = errors.New("the list not found")

	// ErrIndexOutOfRange is returned when use LSet function set index out of range.
	ErrIndexOutOfRange = errors.New("index out of range")

	// ErrCount is returned when count is error.
	ErrCount = errors.New("err count")

	// ErrMinInt is returned when count == math2.MinInt.
	ErrMinInt = errors.New("err MinInt")

	ErrListIsEmpty = errors.New("list is empty")

	ErrStartOrEnd = errors.New("start or end error")
)

Functions

This section is empty.

Types

type List

type List struct {
	Items     map[string][][]byte
	TTL       map[string]uint32
	TimeStamp map[string]uint64
}

List represents the list.

func New

func New() *List

New returns a newly initialized List Object that implements the List.

func (*List) GetListTTL

func (l *List) GetListTTL(key string) (uint32, error)

func (*List) IsEmpty

func (l *List) IsEmpty(key string) (bool, error)

func (*List) IsExpire

func (l *List) IsExpire(key string) bool

func (*List) LInsert

func (l *List) LInsert(key string, index, t int, values ...[]byte) (size int, err error)

LInsert Insert a value at the specified position 0 1 2 3 4 5

↑ = index
values = [6 7]

t = 0 0 1 [6 7] 2 3 4 5 t = 1 0 1 2 [6 7] 3 4 5

func (*List) LPeek

func (l *List) LPeek(key string) (item []byte, err error)

LPeek returns the first element of the list stored at key.

func (*List) LPop

func (l *List) LPop(key string) (item []byte, err error)

LPop removes and returns the first element of the list stored at key.

func (*List) LPush

func (l *List) LPush(key string, values ...[]byte) (size int, err error)

LPush inserts all the specified values at the head of the list stored at key.

func (*List) LRange

func (l *List) LRange(key string, start, end int) (list [][]byte, err error)

LRange returns the specified elements of the list stored at key [start,end]

func (*List) LRem

func (l *List) LRem(key string, count int, value []byte) (int, error)

LRem removes the first count occurrences of elements equal to value from the list stored at key. The count argument influences the operation in the following ways: count > 0: Remove elements equal to value moving from head to tail. count < 0: Remove elements equal to value moving from tail to head. count = 0: Remove all elements equal to value.

func (*List) LRemByIndex

func (l *List) LRemByIndex(key string, indexes []int) (int, error)

LRemByIndex remove the list element at specified index

func (*List) LRemByIndexPreCheck

func (l *List) LRemByIndexPreCheck(key string, indexes []int) (int, error)

LRemByIndexPreCheck count the number of valid indexes

func (*List) LRemNum

func (l *List) LRemNum(key string, count int, value []byte) (int, error)

func (*List) LRemove

func (l *List) LRemove(key string, index int) (item []byte, err error)

LMove 移除指定数据

func (*List) LSet

func (l *List) LSet(key string, index int, value []byte) error

LSet sets the list element at index to value.

func (*List) Ltrim

func (l *List) Ltrim(key string, start, end int) error

Ltrim trim an existing list so that it will contain only the specified range of elements specified.

func (*List) RPeek

func (l *List) RPeek(key string) (item []byte, size int, err error)

RPeek returns the last element of the list stored at key.

func (*List) RPop

func (l *List) RPop(key string) (item []byte, err error)

RPop removes and returns the last element of the list stored at key.

func (*List) RPush

func (l *List) RPush(key string, values ...[]byte) (size int, err error)

RPush inserts all the specified values at the tail of the list stored at key.

func (*List) Size

func (l *List) Size(key string) (int, error)

Size returns the size of the list at given key.

Jump to

Keyboard shortcuts

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