Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Redis way of Data Analytics

Avatar for atmb4u atmb4u
July 26, 2012
210

The Redis way of Data Analytics

Avatar for atmb4u

atmb4u

July 26, 2012

Transcript

  1. Agenda • Learn basics of Redis • Learn basics of

    Python • Develop a web app with Django, and get visitor analytics done – yourself!
  2. Getting Cozy • How many are you on UNIX machines?

    • How many heard about redis? • How many know python? • Installed python, redis server, redis-py and django
  3. What is redis? • A Key-Value store • An In-Memory

    Database • Really Fast - ~1,00,000 reads/sec • Pub/Sub message passing • Supported by VMWare • Developed by Salvatore Sanfilippo and others • Opensource
  4. Basic Operations Set redis.client.sadd("members", "Adam") >>>True redis_client.sadd("members", "Bob") >>>True redis_client.sadd("members",

    "Carol") >>>True redis_client.sadd("members", "Adam") >>>False redis_client.smembers("members") >>>set(['Bob', 'Adam', 'Carol'])
  5. Basic Operations Ordered Set redis.client.zadd("members", "Adam") >>>True redis_client.sadd("members", "Bob") >>>True

    redis_client.sadd("members", "Carol") >>>True redis_client.sadd("members", "Adam") >>>False redis_client.smembers("members") >>>set(['Bob', 'Adam', 'Carol'])
  6. Basic Operations Hashes redis.client.hset("user:tom", "fullname", "Tom Sawyer") 1 redis_client.hset("user:tom", "password",

    "blah") 1 redis_client.hkeys("user:tom") ['fullname', 'password'] redis_client.hvals("user:tom") ['Tom Sawyer', 'blah'] redis_client.hgetall("user:tom") {'fullname': 'Tom Sawyer', 'password': 'blah'}
  7. Why use redis? Sharing keys in-between realms Faster read-write Bit

    level storage access(setbit function) Cheaper logging In-memory caching Master-Slave replication