(key string, ttl int64, values ...interface{})
| 64 | } |
| 65 | |
| 66 | func (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 |
nothing calls this directly
no test coverage detected