GetSet sets the value of a key and returns its old value
(key string, value interface{}, ttl int64)
| 158 | |
| 159 | // GetSet sets the value of a key and returns its old value |
| 160 | func (s *StringStructure) GetSet(key string, value interface{}, ttl int64) (interface{}, error) { |
| 161 | // Get the old value |
| 162 | oldValue, err := s.Get(key) |
| 163 | if err != nil { |
| 164 | return nil, err |
| 165 | } |
| 166 | |
| 167 | // Set the value |
| 168 | err = s.Set(key, value, ttl) |
| 169 | if err != nil { |
| 170 | return nil, err |
| 171 | } |
| 172 | |
| 173 | // Return the old value |
| 174 | return oldValue, nil |
| 175 | } |
| 176 | |
| 177 | // Append appends a value to the value of a key |
| 178 | func (s *StringStructure) Append(key string, v interface{}, ttl int64) error { |