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
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The Redis way of Data Analytics
atmb4u
July 26, 2012
More Decks by atmb4u
See All by atmb4u
Test Driven Development in Python
atmb4u
2
130
Featured
See All Featured
The SEO identity crisis: Don't let AI make you average
varn
0
510
Code Reviewing Like a Champion
maltzj
528
40k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
Discover your Explorer Soul
emna__ayadi
2
1.2k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Leo the Paperboy
mayatellez
7
1.9k
Visualization
eitanlees
152
17k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
HDC tutorial
michielstock
2
730
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