how you can benefit from using redis. javier ramirez, teowaki, at codemotion 2014
DESCRIPTION
All the cool cats are using Redis, and with a reason: It's fast, it's robust, it's easy and it's web scale. Redis is powering sites like twitter, instagram, snapchat, youporn, world of warcraft or pinterest, but you can also benefit from the power of Redis even in a more modest project. In this session I will talk about what is Redis, what you can do with it, how other people are using it, and how we are using it in our startup for a number of common use cases.TRANSCRIPT
![Page 1: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/1.jpg)
by javier ramirez@supercoco9
How you can benefit from using
https://teowaki.com https://datawaki.com
![Page 2: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/2.jpg)
![Page 3: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/3.jpg)
![Page 4: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/4.jpg)
![Page 5: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/5.jpg)
![Page 6: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/6.jpg)
![Page 7: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/7.jpg)
I was Lois Lane
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 8: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/8.jpg)
redis has super powers
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 9: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/9.jpg)
superpower I: super speed
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 10: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/10.jpg)
redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop,mset -P 16 -q
On my laptop:
SET: 513610 requests per secondGET: 641436 requests per secondLPUSH: 845665 requests per secondLPOP: 783392 requests per secondMSET (10 keys): 89988 requests per second
On a small digital ocean server ($5/month)
SET: 227816 requests per secondGET: 228258 requests per secondLPUSH: 251098 requests per secondLPOP: 251572 requests per secondMSET (10 keys): 43918 requests per second
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 11: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/11.jpg)
superpower II: it doesn't hide
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 12: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/12.jpg)
http://redis.io
open source, BSD licensed, advanced key-value store.
It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets and hyperloglogs.
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 13: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/13.jpg)
started in 2009 by Salvatore Sanfilippo @antirez
112 contributors at
https://github.com/antirez/redis
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 14: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/14.jpg)
The Redis Manifesto1.A DSL for Abstract Data Types
2.Memory storage is #1
3.Fundamental data structures for a fundamental API
4.Two levels of API
5.Code is like a poem; it's not just something we write to reach some practical result
6.We're against complexity
7.We optimize for joy
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 15: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/15.jpg)
superpower III: Redis makes You think
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 16: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/16.jpg)
Redis data typesStrings
Hashes
Lists
Sets
Sorted Sets
HyperLogLogsjavier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 17: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/17.jpg)
basic commands
Setting/getting/deleting/expiring
Increment/decrement
Pushing/popping
Checking membership, size...
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 18: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/18.jpg)
much cooler commandsSetting only if exists
Blocking pop
(Blocking) pop from one list, push to another
Get/set string ranges (and bit operations)
Set intersections/diffs (and store)
Pub/subjavier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 19: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/19.jpg)
A chat in 6 lines of code
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
r=Redis.new driver: :hiredisr.subscribe “chatrooms:42” do |on|
on.message do |topic, msg|puts “#{topic}: #{msg}”
endend
r.publish “chatrooms:42”, “Hello codemotion”
![Page 20: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/20.jpg)
superpower IV: atomicity
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 21: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/21.jpg)
single threaded, so no concurrency problems
transactions and lua scripts to run multiple operations atomically
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 22: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/22.jpg)
superpower V: flexible data persistence
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 23: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/23.jpg)
Redis keeps everything in memory all the time
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 24: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/24.jpg)
Does that mean if the server goes down I will lose my data?
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 25: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/25.jpg)
NO**unless you didn't configure it properly
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 26: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/26.jpg)
superpower VI: data distribution
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 27: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/27.jpg)
High Availability & scaling out
One master, several read-only slaves
Sharding, Twemproxy, Dynomite
Redis clusterjavier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 28: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/28.jpg)
what's being used for
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 29: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/29.jpg)
Every time line (800 tweets per user) is on redis
5000 writes per second avg300K reads per second
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 30: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/30.jpg)
user info from gizmoduck(memcached)
user id tweet id metadata
write API (from browser or client app)
rpushx to Redis
tweet info from tweetypie (memcached + mysql)
your twitter timeline
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
fanout (flockDB)
one per follower
![Page 31: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/31.jpg)
Crashlytics
Activity tracking with Strings and Bit Operations
Event tracking with Hashes
Leaderboards with Sorted Sets
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 32: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/32.jpg)
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
soundcloud
Roshi implements a time-series event storage via a LWW-element-set CRDT with inline garbage collection.
Roshi is a stateless, distributed layer on top of Redis and is implemented in Go. It is partition tolerant, highly available and eventually consistent.
https://github.com/soundcloud/roshi
![Page 33: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/33.jpg)
World Of Warcraft
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
Blizzard is quite secretive about it
Known to have at least 8 servers with 64Gb each to serve user avatars
Known to have seen 1.000.000 users concurrently in the Asian version of the game
![Page 34: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/34.jpg)
stack overflowThree level cache:
local cache (no persistence)sessions, and pending view count updates
site cache hot question id lists, user acceptance rates...
global cache (separate Redis DB)Inboxes, API usage quotas...
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 35: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/35.jpg)
tumblr
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
started using Redis for notifications (over 7000/s) because MySQL would struggle.
They liked it, so then they replaced memcached too
![Page 36: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/36.jpg)
Booking.com
2TB of data in server-side cookie sessions
36 masters – 36 slaves in 2 datacenters
Implemented new command to have versioned race-free hash entries
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 37: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/37.jpg)
pinterest object graph
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
per userRedis SortedSet, with timestamp as the score to
store the users followed explicitlystore the users followed implicitlystore the user’s explicit followersstore the user’s implicit followersstore boards followed explicitly
Redis set to store boards unfollowed explicitly
per boardRedis Hash to store a board’s explicit followersRedis Set to store a board’s explicit unfollowers
![Page 38: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/38.jpg)
youporn
Most data is found in hashes with ordered sets used to know what data to show.
zInterStore on: videos:filters:released, Videos:filters:orientation:straight,Videos:filters:categories:{category_id}, Videos:ordering:rating
Then perform a zRange to get the pages we want and get the list of video_ids back.
Then start a pipeline and get all the videos from hashes.
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 39: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/39.jpg)
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
snapchatRedis cluster of 216 master and 216 slaves.Over 400MM messages per day.Running on Google App Engine.No need to have an operations team.
![Page 40: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/40.jpg)
githubGit as a service internally.
Redis is used for storing routing info matching user repositories to server names
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 41: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/41.jpg)
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
hipchatRedis for caching.
Information like which users are in which rooms, presence information, who is online...
Redis to balance XMPP, so it doesn’t matter which XMPP server you connect to.
![Page 42: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/42.jpg)
when things go wrong
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 43: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/43.jpg)
the instagram case
moving from redis to cassandra: 75% savings on servers
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 44: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/44.jpg)
pick the right superhero
![Page 45: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/45.jpg)
the twilio case
credit card hell
lesson learnt: know what you are doing. Don't change config on the fly
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 46: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/46.jpg)
stripe
Master didn't have persistence, but slaves did.
Master was stopped, slaves kept working.
Master was re-started, asked the slaves to replicate the master database (it was empty)
All the data in the cluster was lost.
Luckily, this was only a test, but a scary one.
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 47: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/47.jpg)
take the time to masteryour super powers
![Page 48: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/48.jpg)
everybody fails, sometimes
Salvatore Sanfilippo lost his own blog*because he forgotto configure persistance
* he recovered it in 30 minutes
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 49: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/49.jpg)
superpower VII: it doesn't get scared ofbig numbers
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 50: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/50.jpg)
you can go a long waybefore havingscary numbers
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 51: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/51.jpg)
how teowaki is using redis
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 52: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/52.jpg)
![Page 53: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/53.jpg)
![Page 54: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/54.jpg)
![Page 55: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/55.jpg)
![Page 56: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/56.jpg)
Abusing queues
keep track of every activity in the system, even if you don't need them all right now:- every page view- every API request- every time a record is created/updated/deleted
benefits:- highly decoupled system- easier to divide into services- you can add behaviour without changing your app
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 57: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/57.jpg)
intermediate cache* As a very fast lightweight storage for analytics data before sending them to our google bigquery based solution
* As a cache for attributes frequently looked up in join tables(names, nicknames, guids, delegated or included model names...)
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 58: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/58.jpg)
Some of our uses of LuaExpiring attributes inside a Redis hash
Inserting notifications into a list only if there are notpending notifications from the same user for the same scope
Paginating a list by an attribute
Manipulating JSON directly at the Redis layer
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 59: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/59.jpg)
counters
Atomic counters can be safely invoked concurrently from anywhere, so you can implement “like” features, global sequences or usage monitoring systems in highly concurrent applications for free.
You can share your counters with any other internal application and still be sure they won't collide.
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 60: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/60.jpg)
Temporary dataRedis allows us to self expire keys after a time has passed. You can use this mechanism for a simple cache
If you operate on a key with expiration time, you can change its value and still keep the expiration going. By combining a decrementing counter with an expiration time, implementing usage quotas is trivial
Also, you can inspect which keys you have in your server efficiently using SCAN commands
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 61: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/61.jpg)
bloom filtersbloom filter: space-efficient probabilistic data structure that is used to test whether an element is a member of a set. False positive matches are possible, but false negatives are not.
Redis bit operations make easy to implement bloom filters
We are using bloom filters for checking uniqueness of user names and reserved words without going to postgresql
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 62: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/62.jpg)
nginx + lua + redis
Multiple levels of cache by using Redis on the webserver/middleware layer
http://wiki.nginx.org/HttpRedis
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com
![Page 63: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/63.jpg)
summarizing* Redis is more powerful than it seems
* Very fast, easy to use, simple, good documentation
* In-memory data structures, distributed, shared and persisted
* Good as data store, intermediate data store, cache or queue
* Lots of use cases, both in huge and smaller systems
You should probably use it a lot more
javier ramirez @supercoco9 https://teowaki.com https://datawaki.com https://datawaki.com
![Page 64: How you can benefit from using Redis. Javier Ramirez, teowaki, at Codemotion 2014](https://reader033.vdocuments.us/reader033/viewer/2022060121/559444ed1a28abf32f8b47ea/html5/thumbnails/64.jpg)
Find related links at
https://teowaki.com/teams/javier-community/link-categories/redis
gracias!¡If you enjoyed this talk, please sign up for
https://teowaki.com
Don't forget to invite your friends too!
Javier Ramírez@supercoco9