Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Redis are all hash keys stored in the same "table"? and if so how does it affect performance?

Tags:

redis

Looking at this example http://redis.io/topics/twitter-clone where user records are stored by using a hash key ("uid:1000") and "tweets" are stored by hash key ("post:60"), does this mean that all those records are stored in the same data structure and adding tweets will effect the time for retrieving user records?

like image 422
user971956 Avatar asked May 01 '12 18:05

user971956


People also ask

Does Redis use hash table?

It is implemented as a Hash table and handles collisions by Chaining. A Redis Hash can store up to 4 billion key value pairs. If the value is Integer, Redis hash allows you to atomically increment or decrement the value.

How does Redis hash work?

Redis Hashes are maps between the string fields and the string values. Hence, they are the perfect data type to represent objects. In Redis, every hash can store up to more than 4 billion field-value pairs.

How many keys Redis can store?

Redis can hold 232 keys. A key (not values) can be up to 512MB.

How are Redis keys stored?

Redis is an in-memory non-relational key-value store (sometimes referred to as a data structure server). This means that it stores data based on keys and values — think of it as a giant dictionary that uses words and their definitions to store information.


1 Answers

Yes, the users and tweets are stored in the same data structure. That data structure is a hash table.

Internally, Redis has no concept of record types. As far as Redis is concerned,User:1000 and Post:60 are just a sequence of bytes. So yes, Redis does store all records in the same data structure.

Because Redis does not differentiate between Tweets and Users, the response times for both types of records is going to be similar.

So, everything boils down to the question - "Does Redis' performance scale to the number of records?"

The answer to that is YES, it does. As long as you have the memory to keep all your data, Redis' performance should not depend on the number of records.

like image 97
Sripathi Krishnan Avatar answered Oct 28 '22 23:10

Sripathi Krishnan