the redis way of analyticsANOOP THOMAS MATHEWProfoundis Labs Pvt. Ltd.@atmb4u
Agenda●Learn basics of Redis●Learn basics of Python●Develop a web app with Django,and get visitor analytics done –yourself!
Getting Cozy●How many are you on UNIX machines?●How many heard about redis?●How many know python?●Installed python, redis ...
What is redis?●A Key-Value store●An In-Memory Database●Really Fast - ~1,00,000 reads/sec●Pub/Sub message passing●Supported...
Getting Startedsudo apt-get install redis-serverpip install redis________________________________import redisredis_client ...
Basic DatastructuresStringIntegerListSetOrdered SetHashes
Basic OperationsStringredis_client.set(“key”, “value”)redis_client.get(“key”)>>> value
Basic OperationsIntegerredis_client.set(“number”, 1)redis_client.get(“number”)>>> 1redis_client.incr(“number”)redis_client...
Basic OperationsListredis_client.rpush(“member”, “ATM”)redis_client.rpush(“member”, “HasGeek”)redis_client.lrange("members...
Basic OperationsSetredis.client.sadd("members", "Adam")>>>Trueredis_client.sadd("members", "Bob")>>>Trueredis_client.sadd(...
Basic OperationsOrdered Setredis.client.zadd("members", "Adam")>>>Trueredis_client.sadd("members", "Bob")>>>Trueredis_clie...
Basic AOperationsHashesredis.client.hset("user:tom", "fullname", "Tom Sawyer")1redis_client.hset("user:tom", "password", "...
Publish - Subscribepubsub = redis_client.pubsub()pubsub.subscribe(red)pubsub.publish(red, qube)for item in pubsub.listen()...
Why use redis?Sharing keys in-between realmsFaster read-writeBit level storage access(setbit function)Cheaper loggingIn-me...
Lets go Hands On!
Final Product!https://bitbucket.org/atmb4u/hitcounter.git
Profoundis LabsWhat we do?&We are hiring!(atm@profoundis.com)
Get in Touchatm@profoundis.com@atmb4u+91 - 999 53 44 675
Upcoming SlideShare
Loading in...5
×

Redis way of Anayltics with Python - Fifth Elephant 2012

1,154

Published on

The Redis way of Analytics with Python. As a workshop for Fifth Elephant conference 2012.

Published in: Technology, Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,154
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Redis way of Anayltics with Python - Fifth Elephant 2012

  1. 1. the redis way of analyticsANOOP THOMAS MATHEWProfoundis Labs Pvt. Ltd.@atmb4u
  2. 2. Agenda●Learn basics of Redis●Learn basics of Python●Develop a web app with Django,and get visitor analytics done –yourself!
  3. 3. Getting Cozy●How many are you on UNIX machines?●How many heard about redis?●How many know python?●Installed python, redis server, redis-pyand django
  4. 4. 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 andothers●Opensource
  5. 5. Getting Startedsudo apt-get install redis-serverpip install redis________________________________import redisredis_client = redis.Redis(“localhost”)
  6. 6. Basic DatastructuresStringIntegerListSetOrdered SetHashes
  7. 7. Basic OperationsStringredis_client.set(“key”, “value”)redis_client.get(“key”)>>> value
  8. 8. Basic OperationsIntegerredis_client.set(“number”, 1)redis_client.get(“number”)>>> 1redis_client.incr(“number”)redis_client.get(“number”)>>> 2redis_client.get(“number”)redis_client.decr(“number”)>>> 1
  9. 9. Basic OperationsListredis_client.rpush(“member”, “ATM”)redis_client.rpush(“member”, “HasGeek”)redis_client.lrange("members", 0, -1)[ATM, HasGeek]redis_client.llen("members")2redis_client.lindex("members", 1)HasGeek
  10. 10. Basic OperationsSetredis.client.sadd("members", "Adam")>>>Trueredis_client.sadd("members", "Bob")>>>Trueredis_client.sadd("members", "Carol")>>>Trueredis_client.sadd("members", "Adam")>>>Falseredis_client.smembers("members")>>>set([Bob, Adam, Carol])
  11. 11. Basic OperationsOrdered Setredis.client.zadd("members", "Adam")>>>Trueredis_client.sadd("members", "Bob")>>>Trueredis_client.sadd("members", "Carol")>>>Trueredis_client.sadd("members", "Adam")>>>Falseredis_client.smembers("members")>>>set([Bob, Adam, Carol])
  12. 12. Basic AOperationsHashesredis.client.hset("user:tom", "fullname", "Tom Sawyer")1redis_client.hset("user:tom", "password", "blah")1redis_client.hkeys("user:tom")[fullname, password]redis_client.hvals("user:tom")[Tom Sawyer, blah]redis_client.hgetall("user:tom"){fullname: Tom Sawyer, password: blah}
  13. 13. Publish - Subscribepubsub = redis_client.pubsub()pubsub.subscribe(red)pubsub.publish(red, qube)for item in pubsub.listen():print item
  14. 14. Why use redis?Sharing keys in-between realmsFaster read-writeBit level storage access(setbit function)Cheaper loggingIn-memory cachingMaster-Slave replication
  15. 15. Lets go Hands On!
  16. 16. Final Product!https://bitbucket.org/atmb4u/hitcounter.git
  17. 17. Profoundis LabsWhat we do?&We are hiring!(atm@profoundis.com)
  18. 18. Get in Touchatm@profoundis.com@atmb4u+91 - 999 53 44 675

×