Documentation ¶
Overview ¶
Example ¶
package main import "fmt" var listKey = "my_list" func main() { list := New() list.LPush(listKey, [][]byte{[]byte("a"), []byte("b"), []byte("c")}...) list.RPush(listKey, [][]byte{[]byte("a"), []byte("b"), []byte("c")}...) list.LPop(listKey) list.RPop(listKey) length := list.LLen(listKey) fmt.Println(length) list.LSet(listKey, 10, []byte("d")) }
Output:
Index ¶
- type InsertOption
- type List
- func (lis *List) LClear(key string)
- func (lis *List) LIndex(key string, index int) []byte
- func (lis *List) LInsert(key string, option InsertOption, pivot, val []byte) int
- func (lis *List) LKeyExists(key string) (ok bool)
- func (lis *List) LLen(key string) int
- func (lis *List) LPop(key string) []byte
- func (lis *List) LPush(key string, val ...[]byte) int
- func (lis *List) LRange(key string, start, end int) [][]byte
- func (lis *List) LRem(key string, val []byte, count int) int
- func (lis *List) LSet(key string, index int, val []byte) bool
- func (lis *List) LTrim(key string, start, end int) bool
- func (lis *List) LValExists(key string, val []byte) (ok bool)
- func (lis *List) RPop(key string) []byte
- func (lis *List) RPush(key string, val ...[]byte) int
- type Record
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InsertOption ¶
type InsertOption uint8
InsertOption insert option for LInsert.
const ( // Before insert before pivot. Before InsertOption = iota // After insert after pivot. After )
type List ¶
type List struct {
// contains filtered or unexported fields
}
List list idx.
func (*List) LIndex ¶
LIndex returns the element at index index in the list stored at key. The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here, -1 means the last element, -2 means the penultimate and so forth.
func (*List) LInsert ¶
func (lis *List) LInsert(key string, option InsertOption, pivot, val []byte) int
LInsert inserts element in the list stored at key either before or after the reference value pivot.
func (*List) LKeyExists ¶ added in v1.2.8
LKeyExists check if the key of a List exists.
func (*List) LLen ¶
LLen returns the length of the list stored at key. If key does not exist, it is interpreted as an empty list and 0 is returned.
func (*List) LPush ¶
LPush insert all the specified values at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations.
func (*List) LRange ¶
LRange returns the specified elements of the list stored at key. The offsets start and stop are zero-based indexes, with 0 being the first element of the list (the head of the list), 1 being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list. For example, -1 is the last element of the list, -2 the penultimate, and so on.
func (*List) LRem ¶
LRem removes the first count occurrences of elements equal to element from the list stored at key. The count argument influences the operation in the following ways: count > 0: Remove elements equal to element moving from head to tail. count < 0: Remove elements equal to element moving from tail to head. count = 0: Remove all elements equal to element.
func (*List) LTrim ¶
LTrim trim an existing list so that it will contain only the specified range of elements specified. Both start and stop are zero-based indexes, where 0 is the first element of the list (the head), 1 the next element and so on.
func (*List) LValExists ¶ added in v1.2.8
LValExists check if the val exists in a specified List stored at key.