DecrBy decrements the integer value of a key by the given amount
(key string, amount int, ttl int64)
| 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 { |
| 293 | // Get the old value |
| 294 | oldValue, err := s.Get(key) |
| 295 | if err != nil { |
| 296 | return err |
| 297 | } |
| 298 | |
| 299 | // Convert the old value to an integer |
| 300 | intValue, err := convertToInt(oldValue) |
| 301 | if err != nil { |
| 302 | return err |
| 303 | } |
| 304 | |
| 305 | // Decrement the integer value |
| 306 | newIntValue := intValue - amount |
| 307 | |
| 308 | newValue := strconv.Itoa(newIntValue) |
| 309 | |
| 310 | // Set the value |
| 311 | return s.Set(key, newValue, ttl) |
| 312 | } |
| 313 | |
| 314 | // Keys returns all keys matching pattern |
| 315 | func (s *StringStructure) Keys(regx string) ([]string, error) { |
nothing calls this directly
no test coverage detected