Append appends a value to the value of a key
(key string, v interface{}, ttl int64)
| 176 | |
| 177 | // Append appends a value to the value of a key |
| 178 | func (s *StringStructure) Append(key string, v interface{}, ttl int64) error { |
| 179 | // Get the old value |
| 180 | oldValue, err := s.Get(key) |
| 181 | if err != nil { |
| 182 | return err |
| 183 | } |
| 184 | |
| 185 | value, err, _ := interfaceToBytes(v) |
| 186 | if err != nil { |
| 187 | return err |
| 188 | } |
| 189 | |
| 190 | // Convert the old value to a byte slice |
| 191 | oldValueType := []byte(oldValue.(string)) |
| 192 | |
| 193 | // Append the value |
| 194 | newValue := append(oldValueType, value...) |
| 195 | |
| 196 | // Set the value |
| 197 | return s.Set(key, string(newValue), ttl) |
| 198 | } |
| 199 | |
| 200 | // Incr increments the integer value of a key by 1 |
| 201 | func (s *StringStructure) Incr(key string, ttl int64) error { |
nothing calls this directly
no test coverage detected