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)
| 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 |
| 49 | func (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 | |
| 66 | func (l *ListStructure) LPushs(key string, ttl int64, values ...interface{}) error { |
| 67 | // Check if values are valid |
nothing calls this directly
no test coverage detected