MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / LPush

Method LPush

structure/list.go:49–64  ·  view source on GitHub ↗

LPush adds a value to the left of the list corresponding to the key If the key does not exist, it will create the key

(key string, value interface{}, ttl int64)

Source from the content-addressed store, hash-verified

47// LPush adds a value to the left of the list corresponding to the key
48// If the key does not exist, it will create the key
49func (l *ListStructure) LPush(key string, value interface{}, ttl int64) error {
50 // Get the list
51 lst, _, err := l.getListFromDB(key, true)
52 if err != nil {
53 return err
54 }
55 var expirationTime time.Duration
56 newNode := &listNode{
57 Value: value,
58 Next: lst.Head,
59 }
60 lst.Head = newNode
61 lst.Length++
62 expirationTime = time.Duration(ttl) * time.Second
63 return l.setListToDB(key, lst, expirationTime)
64}
65
66func (l *ListStructure) LPushs(key string, ttl int64, values ...interface{}) error {
67 // Check if values are valid

Callers

nothing calls this directly

Calls 2

getListFromDBMethod · 0.95
setListToDBMethod · 0.95

Tested by

no test coverage detected