Exists checks if a key exists
(key string)
| 336 | |
| 337 | // Exists checks if a key exists |
| 338 | func (s *StringStructure) Exists(key string) (bool, error) { |
| 339 | // Get the value |
| 340 | _, err := s.Get(key) |
| 341 | if err != nil { |
| 342 | if err == _const.ErrKeyNotFound { |
| 343 | return false, nil |
| 344 | } |
| 345 | return false, err |
| 346 | } |
| 347 | |
| 348 | return true, nil |
| 349 | } |
| 350 | |
| 351 | // Expire sets the expiration time of a key |
| 352 | func (s *StringStructure) Expire(key string, ttl int64) error { |