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

Method LPushs

structure/list.go:66–90  ·  view source on GitHub ↗
(key string, ttl int64, values ...interface{})

Source from the content-addressed store, hash-verified

64}
65
66func (l *ListStructure) LPushs(key string, ttl int64, values ...interface{}) error {
67 // Check if values are valid
68 if len(values) == 0 {
69 return ErrInvalidArgs
70 }
71
72 // Get the list
73 lst, _, err := l.getListFromDB(key, true)
74 if err != nil {
75 return err
76 }
77 var expirationTime time.Duration
78 for i := len(values) - 1; i >= 0; i-- {
79 newNode := &listNode{
80 Value: values[i],
81 Next: lst.Head,
82 }
83 lst.Head = newNode
84 lst.Length++
85 }
86 expirationTime = time.Duration(ttl) * time.Second
87
88 // Store to db
89 return l.setListToDB(key, lst, expirationTime)
90}
91
92// RPush adds a value to the right of the list corresponding to the key
93// If the key does not exist, it will create the key

Callers

nothing calls this directly

Calls 2

getListFromDBMethod · 0.95
setListToDBMethod · 0.95

Tested by

no test coverage detected