Keys returns all the keys of the list structure.
(regx string)
| 435 | |
| 436 | // Keys returns all the keys of the list structure. |
| 437 | func (l *ListStructure) Keys(regx string) ([]string, error) { |
| 438 | toRegexp := convertToRegexp(regx) |
| 439 | compile, err := regexp.Compile(toRegexp) |
| 440 | if err != nil { |
| 441 | return nil, err |
| 442 | } |
| 443 | var keys []string |
| 444 | byteKeys := l.db.GetListKeys() |
| 445 | for _, key := range byteKeys { |
| 446 | // match prefix and key |
| 447 | if compile.MatchString(string(key)) { |
| 448 | // check if deleted |
| 449 | db, _, err := l.getListFromDB(string(key), true) |
| 450 | if err != nil { |
| 451 | continue |
| 452 | } |
| 453 | if db.Length == 0 { |
| 454 | continue |
| 455 | } |
| 456 | keys = append(keys, string(key)) |
| 457 | } |
| 458 | } |
| 459 | return keys, nil |
| 460 | } |
| 461 | |
| 462 | // RPOPLPUSH removes the last element from one list and pushes it to another list. |
| 463 | // If the source list is empty, an error is returned. |
nothing calls this directly
no test coverage detected