Home » TechNote » Introduction to Redis

Introduction to Redis

What is Redis?

http://blog.newrelic.com/wp-content/uploads/redis.png
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 !


Key features:

  • Get/Set/Incr strings or numbers
  • Lists
    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.

    http://s24.postimg.org/afq4ccxlh/redis_lists.jpg Simple Redis list

  • Sets
    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
  • Hash
    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
  • Transactions
 

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:

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..
  • Analytics
  • Task queues
  • Distributed locks
  • Caching
  • Data that expires
  • Cookie storage
  • Search engines
  • Ad targeting
  • Forums
  • Messaging
  • High-IO workloads
 

Who is using Redis?

  • Pinterest
  • Rackspace
  • Blizzard Entertainment
  • Digg
  • Stackoverflow
  • Craigslist
  • Twitter
  • Github
 

Install Redis

For CentOS


For Windows

Download Redis for Windows at: https://github.com/dmajkic/redis/downloads

For Mac OS

The instructions will stay pretty much same for CentOS or you can try: