Decr decrements the integer value of a key by 1
(key string, ttl int64)
| 267 | |
| 268 | // Decr decrements the integer value of a key by 1 |
| 269 | func (s *StringStructure) Decr(key string, ttl int64) error { |
| 270 | // Get the old value |
| 271 | oldValue, err := s.Get(key) |
| 272 | if err != nil { |
| 273 | return err |
| 274 | } |
| 275 | |
| 276 | // Convert the old value to an integer |
| 277 | intValue, err := convertToInt(oldValue) |
| 278 | if err != nil { |
| 279 | return err |
| 280 | } |
| 281 | |
| 282 | // Decrement the integer value |
| 283 | newIntValue := intValue - 1 |
| 284 | |
| 285 | newValue := strconv.Itoa(newIntValue) |
| 286 | |
| 287 | // Set the value |
| 288 | return s.Set(key, newValue, ttl) |
| 289 | } |
| 290 | |
| 291 | // DecrBy decrements the integer value of a key by the given amount |
| 292 | func (s *StringStructure) DecrBy(key string, amount int, ttl int64) error { |
nothing calls this directly
no test coverage detected