list

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2019 License: Apache-2.0 Imports: 1 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")
)

Functions

This section is empty.

Types

type List

type List struct {
	Items map[string][][]byte
}

List represents the list.

func New

func New() *List

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

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) (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) 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