Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
Josh Baker edited this page Oct 11, 2016 · 14 revisions

ITER index [PIVOT value] [MATCH pattern] [RANGE min max] [LIMIT limit] [DESC|ASC]

Iterate through a specified index. This works in a similar manner to KEYS.

This operation is very fast because the values are stored in a B-tree.

Please keep in mind that the default LIMIT is 100. This is to keep from having an accidental ITER index command on an index with lots of values. When specified, LIMIT is not constrained to 100 and can be any positive number.

Options

  • PIVOT value - The results will include all keys past value
  • MATCH pattern - Limit results to keys that match the specified pattern
  • RANGE min max - Constrain the result between specified range. The values -inf and +inf may be used for boundless ranges. To return a single item you should use the RANGE with min and max being the same value, and LIMIT equal to 1.
  • LIMIT limit - Limit the number of results. The default is 100
  • DESC - Return the results in descending order

Supported glob-style patterns for the MATCH option:

  • h?llo matches hello, hallo and hxllo
  • h*llo matches hllo and heeeello

Return value

Array reply: list of results.

Examples

redis> SETINDEX names user:*:name TEXT
OK
redis> SET user:0:name tom
OK
redis> SET user:1:name Randi
OK
redis> SET user:2:name jane
OK
redis> SET user:4:name Janet
OK
redis> SET user:5:name Paula
OK
redis> SET user:6:name peter
OK
redis> SET user:7:name Terri
OK
redis> ITER names
 1) "user:2:name"
 2) "jane"
 3) "user:4:name"
 4) "Janet"
 5) "user:5:name"
 6) "Paula"
 7) "user:6:name"
 8) "peter"
 9) "user:1:name"
10) "Randi"
11) "user:7:name"
12) "Terri"
13) "user:0:name"
14) "tom"
redis> ITER names MATCH *2*
1) "user:2:name"
2) "jane"
redis> ITER names LIMIT 3
1) "user:2:name"
2) "jane"
3) "user:4:name"
4) "Janet"
5) "user:5:name"
6) "Paula"
redis> ITER names LIMIT 3
1) "user:2:name"
2) "jane"
3) "user:4:name"
4) "Janet"
5) "user:5:name"
6) "Paula"
redis> ITER names RANGE matt peter
1) "user:5:name"
2) "Paula"
3) "user:6:name"
4) "peter"
redis> ITER names RANGE matt peter LIMIT 1
1) "user:5:name"
2) "Paula"
redis> ITER names RANGE matt +inf
 1) "user:5:name"
 2) "Paula"
 3) "user:6:name"
 4) "peter"
 5) "user:1:name"
 6) "Randi"
 7) "user:7:name"
 8) "Terri"
 9) "user:0:name"
10) "tom"

Clone this wiki locally