[フレーム]
Docs Pricing
Login Book a meeting Try Redis

VRANGE

Syntax
VRANGE key start end [count]
Available since:
Redis Open Source 8.4.0
Time complexity:
O(log(K)+M) where K is the number of elements in the start prefix, and M is the number of elements returned. In practical terms, the command is just O(M)

The VRANGE command provides a stateless iterator for the elements inside a vector set. It allows you to retrieve all the elements inside a vector set in small amounts for each call, without an explicit cursor, and with guarantees about what you will miss in case the vector set is changing (elements added and/or removed) during the iteration.

The command returns elements in lexicographical order, using byte-by-byte comparison (like memcmp()) to establish a total order among elements.

Required arguments

key

The name of the vector set key from which to retrieve elements.

start

The starting point of the lexicographical range. Can be:

  • A string prefixed with [ for inclusive range (e.g., [Redis)
  • A string prefixed with ( for exclusive range (e.g., (a7)
  • The special symbol - to indicate the minimum element
end

The ending point of the lexicographical range. Can be:

  • A string prefixed with [ for inclusive range
  • A string prefixed with ( for exclusive range
  • The special symbol + to indicate the maximum element

Optional arguments

count

The maximum number of elements to return. If count is negative, the command returns all elements in the specified range (which may block the server for a long time with large sets).

Examples

Retrieve the first 10 elements starting from the string "Redis" (inclusive):

VRANGE word_embeddings [Redis + 10

Iterate through all elements, 10 at a time:

VRANGE mykey - + 10

Continue iteration from the last element of the previous result (exclusive):

VRANGE mykey (a7 + 10

Return all elements in the set (use with caution):

VRANGE mykey - + -1

Return information

One of the following:

  • Array reply of elements in lexicographical order within the specified range.
  • Array reply (empty array) if the key doesn't exist.

Behavior

RATE THIS PAGE
Back to top ↑

AltStyle によって変換されたページ (->オリジナル) /