What is Redis?
Redis, standing for REmote DIctionary Server is a NoSQL databases Server. Written in ANSI C by Salvatore Sanfilippo in early 2009 and quickly become the most popular key-value store.
Similar to Memcache, Redis has in-memory key/value store but with extra features like: persistence, more value types(lists, sets, sorted sets, hash table..), open source with large community and of course, it’s FREE !
- Get/Set/Incr strings or numbers
Redis Lists are simply lists of strings, sorted by insertion order. It is possible to add elements to a Redis List pushing new elements on the head (on the left) or on the tail (on the right) of the list.
Simple Redis list
Redis Sets are an unordered collection of Strings. It is possible to add, remove, and test for existence of members Set
- Sorted sets
Redis Sorted Sets are, similarly to Redis Sets, non repeating collections of Strings. The difference is that every member of a Sorted Set is associated with score, that is used in order to take the sorted set ordered, from the smallest to the greatest score. While members are unique, scores may be repeated
Redis Hashes are maps between string fields and string values, so they are the perfect data type to represent objects
- Pub/Subs supported
- Multiple databases
Why Redis?It’s fast, almost data is in memory so we can access them instantly, master/slave replication – any slaves can become masters on the fly. With tons of features, we can implement Redis in many cases.
Sample Redis query:
SET name "John"
Easy huh? 😉
When using Redis?Redis is good for many cases, and below is list of some cases that was implemented by big companies like Twitted, Pinterest, Disqus, Instagram..
- Task queues
- Distributed locks
- Data that expires
- Cookie storage
- Search engines
- Ad targeting
- High-IO workloads
Who is using Redis?
- Blizzard Entertainment
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
yum install redis -y
For WindowsDownload Redis for Windows at: https://github.com/dmajkic/redis/downloads
For Mac OSThe instructions will stay pretty much same for CentOS or you can try:
curl -O http://download.redis.io/redis-stable.tar.gz
tar -xvzf redis-stable.tar.gz
sudo make install