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?
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.
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.
Redis can hold 232 keys. A key (not values) can be up to 512MB.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With