Incr increments the integer value of a key by 1
(key string, ttl int64)
| 199 | |
| 200 | // Incr increments the integer value of a key by 1 |
| 201 | func (s *StringStructure) Incr(key string, ttl int64) error { |
| 202 | // Get the old value |
| 203 | oldValue, err := s.Get(key) |
| 204 | if err != nil { |
| 205 | return err |
| 206 | } |
| 207 | |
| 208 | intValue, err := convertToInt(oldValue) |
| 209 | if err != nil { |
| 210 | return err |
| 211 | } |
| 212 | |
| 213 | // Increment the integer value |
| 214 | newIntValue := intValue + 1 |
| 215 | |
| 216 | // Convert the new integer value to a byte slice |
| 217 | newValue := strconv.Itoa(newIntValue) |
| 218 | |
| 219 | // Set the value |
| 220 | return s.Set(key, newValue, ttl) |
| 221 | } |
| 222 | |
| 223 | // IncrBy increments the integer value of a key by the given amount |
| 224 | func (s *StringStructure) IncrBy(key string, amount int, ttl int64) error { |
nothing calls this directly
no test coverage detected