From the latest writings
REDIS Benchmark on Amazon EC2, Slicehost and Rackspace Cloud
As you already probably know Redis is not a plain key-value store, actually it is a data structures server, supporting different kind of values. That is, you can't just set strings as values of keys. All the following data types are supported as values: Binary-safe strings, Lists of binary-safe strings, Sets of binary-safe strings, that are collection of unique unsorted elements. You can think at this as a Ruby hash where all the keys are set to the 'true' value, Sorted sets, similar to Sets but where every element is associated to a floating number score. The elements are taken sorted by score. You can think at this as Ruby hashes where the key is the element and the value is the score, but where elements are always taken in order without requiring a sorting operation. It's not always trivial to grasp how this data types work and what to use in order to solve a given problem from the Redis command reference, so this document is a crash course to Redis data types and their most used patterns.
For all the examples we'll use the redis-cli utility, that's a simple but handy command line utility to issue commands against the Redis server.
Redis keys
Before to start talking about the different kind of values supported by Redis it is better to start saying that keys are not binary safe strings in Redis, but just strings not containing a space or a newline character. For instance "foo" or "123456789" or "foo_bar" are valid keys, while "hello world" or "hello\n" are not.
Actually there is nothing inside the Redis internals preventing the use of binary keys, it's just a matter of protocol, and actually the new protocol introduced with Redis 1.2 (1.2 betas are 1.1.x) in order to implement commands like MSET, is totally binary safe. Still for now consider this as an hard limit as the database is only tested with "normal" keys.
A few other rules about keys:
- Too long keys are not a good idea, for instance a key of 1024 bytes is not a good idea not only memory-wise, but also because the lookup of the key in the dataset may require several costly key-comparisons.
- Too short keys are not a good idea. There is no point in writing "u:1000:pwd" as key if you can write instead "user:1000:password", the latter is more readable and the added space is very little compared to the space used by the key object itself.
- Try to stick with a schema. For instance "object-type:id:field" can be a nice idea, like in "user:1000:password". I like to use dots for multi-words fields, like in "comment:1234:reply.to".
Source: Redis Wiki
Cahie categories
- Email bogdan.gaza@info.uaic.ro
- bogdan.gaza@yahoo.com
- contact@cadmio.org
- Twitter hurrycane
- Facebook bogdan.gaza
- Linkedin Bogdan Gaza
- Intel Core 2 Duo E68500
- Gigabyte EP35C-DS3R
- Mushkin HP2-6400 2x1GB CL4
- Antec NSK658
- WD Black Edition 500GB 32MB cache
- Sapphire ATI RADEON 3650
- Samsung 2032BW
- Logitech Wave KB & VX Revolusion





