What is keyspace in redis ?
Asked Answered
P

2

15

I am new to redis, I do not know the meaning of "keyspace" and "key space" in redis terminology which I encountered in redis official website. Can someone help me to clear that? Thanks.

Pesticide answered 15/11, 2018 at 8:47 Comment(0)
P
12

These terms refer to the internal dictionary that Redis manages, in which all keys are stored. The keyspace of a Redis database is managed by a single server in the case of a single instance deployment, and is divided to exclusive slot ranges managed by different nodes when using cluster mode.

Pilose answered 15/11, 2018 at 13:51 Comment(4)
does every key space has its own listener thread or is it shared between all kespaces?Shoelace
What do you mean by "listener"?Pilose
Sorry, wrong wording. Ignore the word "listener", the question is if Redis uses the same thread for all key spaces or a separate thread for each keyspace. Would KEYS * on one keyspace block the other?Shoelace
A single Redis instance, whether standalone or clustered, has a single keyspace. In standalone mode, the keyspace can be further logically segmented into logical databases ("namespaces"), but they are all a part of the same keyspace. Redis is mostly single-threaded, where single means the data access path for all writes and most reads. So yeah, single-threaded would be your answer, I guess.Pilose
D
2

In a key-value database, all keys can be in one node or divided in multiple nodes. Suppose I am storing telephone dictionary as key-value store with name as key and phone number as a value. If I store names A-L on one node and M-Z on another node, I divide my database into two key spaces. When I run query to search number of Smith, I need to search only second key space or node. This divides the query on multiple nodes and divide the work giving faster result. This could be shared-nothing model of working.

Dunning answered 13/10, 2022 at 20:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.