Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The Redis way of Data Analytics
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
atmb4u
July 26, 2012
0
210
The Redis way of Data Analytics
atmb4u
July 26, 2012
Tweet
Share
More Decks by atmb4u
See All by atmb4u
Test Driven Development in Python
atmb4u
2
120
Featured
See All Featured
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
110
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
1
100
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
54
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Ruling the World: When Life Gets Gamed
codingconduct
0
140
Become a Pro
speakerdeck
PRO
31
5.8k
The Curious Case for Waylosing
cassininazir
0
240
New Earth Scene 8
popppiees
1
1.5k
sira's awesome portfolio website redesign presentation
elsirapls
0
150
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
71k
Transcript
the redis way of analytics ANOOP THOMAS MATHEW Profoundis Labs
Pvt. Ltd.
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 server, redis-py and django
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
Getting Started sudo apt-get install redis-server pip install redis ________________________________
import redis redis_client = redis.Redis(“localhost”)
Basic Datastructures String Integer List Set Ordered Set Hashes
Basic Operations String redis_client.set(“key”, “value”) redis_client.get(“key”) >>> 'value'
Basic Operations Integer redis_client.set(“number”, 1) redis_client.get(“number”) >>> '1' redis_client.incr(“number”) redis_client.get(“number”)
>>> '2' redis_client.get(“number”) redis_client.decr(“number”) >>> '1'
Basic Operations List redis_client.rpush(“member”, “ATM”) redis_client.rpush(“member”, “HasGeek”) redis_client.lrange("members", 0, -1)
['ATM', 'HasGeek'] redis_client.llen("members") 2 redis_client.lindex("members", 1) 'HasGeek'
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'])
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'])
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'}
Publish - Subscribe pubsub = redis_client.pubsub() pubsub.subscribe('red') pubsub.publish('red', 'qube') for
item in pubsub.listen(): print item
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
Let's go Hands On!
Final Product! https://bitbucket.org/atmb4u/hitcounter.git
Profoundis Labs What we do? & We are hiring! (
[email protected]
)
Get in Touch
[email protected]
#atmb4u 999 53 44 675