MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / LPush

Method LPush

tx_list.go:148–170  ·  view source on GitHub ↗

LPush inserts the values at the head of the list stored in the bucket at given bucket,key and values.

(bucket string, key []byte, values ...[]byte)

Source from the content-addressed store, hash-verified

146
147// LPush inserts the values at the head of the list stored in the bucket at given bucket,key and values.
148func (tx *Tx) LPush(bucket string, key []byte, values ...[]byte) error {
149 if err := tx.isKeyValid(bucket, key); err != nil {
150 return err
151 }
152
153 if strings.Contains(string(key), SeparatorForListKey) {
154 return ErrSeparatorForListKey
155 }
156
157 for _, value := range values {
158 l, err := tx.getListWithDefault(bucket)
159 if err != nil {
160 return err
161 }
162 newKey := l.GeneratePushKey(key, true)
163 err = tx.push(bucket, newKey, DataLPushFlag, value)
164 if err != nil {
165 return err
166 }
167 }
168
169 return nil
170}
171
172func (tx *Tx) isKeyValid(bucket string, key []byte) error {
173 if err := tx.checkTxIsClosed(); err != nil {

Callers 7

buildListIdxMethod · 0.45
txPushFunction · 0.45
txMPushFunction · 0.45
testRPushAndLPushFunction · 0.45

Calls 4

isKeyValidMethod · 0.95
getListWithDefaultMethod · 0.95
pushMethod · 0.95
GeneratePushKeyMethod · 0.80