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
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
Automating Front-end Workflow
addyosmani
1370
200k
The Cost Of JavaScript in 2023
addyosmani
51
8.6k
Side Projects
sachag
455
43k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Thoughts on Productivity
jonyablonski
69
4.7k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
Building Adaptive Systems
keathley
43
2.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
How STYLIGHT went responsive
nonsquared
100
5.6k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.3k
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