Keys returns all keys matching pattern
(regx string)
| 313 | |
| 314 | // Keys returns all keys matching pattern |
| 315 | func (s *StringStructure) Keys(regx string) ([]string, error) { |
| 316 | toRegexp := convertToRegexp(regx) |
| 317 | compile, err := regexp.Compile(toRegexp) |
| 318 | if err != nil { |
| 319 | return nil, err |
| 320 | } |
| 321 | var keys []string |
| 322 | byteKeys := s.db.GetListKeys() |
| 323 | for _, key := range byteKeys { |
| 324 | if compile.MatchString(string(key)) { |
| 325 | // check if key is expired |
| 326 | _, err := s.Get(string(key)) |
| 327 | if err != nil { |
| 328 | continue |
| 329 | } |
| 330 | keys = append(keys, string(key)) |
| 331 | } |
| 332 | |
| 333 | } |
| 334 | return keys, nil |
| 335 | } |
| 336 | |
| 337 | // Exists checks if a key exists |
| 338 | func (s *StringStructure) Exists(key string) (bool, error) { |
nothing calls this directly
no test coverage detected