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
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
Context Engineering - Making Every Token Count
addyosmani
3
150
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
600
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Become a Pro
speakerdeck
PRO
29
5.5k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
4 Signs Your Business is Dying
shpigford
185
22k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
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