Redis and its many uses   Christian Joudrey - @cjoudrey
‘‘Redis is an open source, advanced key-value store.                             ’’
Key-value what?!
SET name "fido"GET name=> "fido"
EXPIRE name 120
So its likememcached?
Atomic operations
SET count 0INCR count=> 1
Ordered lists
LPUSH friends "Tom"LPUSH friends "Sam"LLEN friends=> 2
LPUSH           RPUSH        Sam   Tom
LRANGE friends 0 0=> ["Sam"]LRANGE friends 0 -1=> ["Sam", "Tom"]
Sets, Hashes, Sorted Sets
Save to disk
Download ithttp://redis.io/download... and try it ...    $ redis-cli    redis> SET name "Chris"    OK    redis> GET name  ...
What about node?!
GitHub   http://git.io/redis... or via npm ...    $ npm install redis
Use case #1:Caching
var redis = require(redis),    client = redis.createClient();function getSomeValue (callback) {   client.get(someVal, func...
Use case #2:Session store
var app = require(express).createServer();var RedisStore = require(connect-redis)(express);app.use(express.session({     s...
Use case #3:Pub/Sub
Chat                ChatServer              Server          Load         Balancer
Use case #4:Job Queue
i.e.:Image resize API
1) Download image   2) Resize image with GD            Node            ServerGET /image_resize?url=http://...
orker                     Job      Resize                               Queue      Workers1) Download image              N...
Kuehttps://github.com/learnboost/kue
Theres a lot more! 11 Common Web Use Cases Solved in Redis           http://bit.ly/pgDmXn
Questions? :)
Upcoming SlideShare
Loading in …5
×

Redis and its many use cases

9,168
-1

Published on

Talk given at NodeMTL #5

Published in: Technology, Design
0 Comments
21 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
9,168
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
108
Comments
0
Likes
21
Embeds 0
No embeds

No notes for slide

Redis and its many use cases

  1. 1. Redis and its many uses Christian Joudrey - @cjoudrey
  2. 2. ‘‘Redis is an open source, advanced key-value store. ’’
  3. 3. Key-value what?!
  4. 4. SET name "fido"GET name=> "fido"
  5. 5. EXPIRE name 120
  6. 6. So its likememcached?
  7. 7. Atomic operations
  8. 8. SET count 0INCR count=> 1
  9. 9. Ordered lists
  10. 10. LPUSH friends "Tom"LPUSH friends "Sam"LLEN friends=> 2
  11. 11. LPUSH RPUSH Sam Tom
  12. 12. LRANGE friends 0 0=> ["Sam"]LRANGE friends 0 -1=> ["Sam", "Tom"]
  13. 13. Sets, Hashes, Sorted Sets
  14. 14. Save to disk
  15. 15. Download ithttp://redis.io/download... and try it ... $ redis-cli redis> SET name "Chris" OK redis> GET name "Chris"
  16. 16. What about node?!
  17. 17. GitHub http://git.io/redis... or via npm ... $ npm install redis
  18. 18. Use case #1:Caching
  19. 19. var redis = require(redis), client = redis.createClient();function getSomeValue (callback) { client.get(someVal, function (err, val) { if (val) return callback(null, val); // Do call directly to Db // and cache result. });};
  20. 20. Use case #2:Session store
  21. 21. var app = require(express).createServer();var RedisStore = require(connect-redis)(express);app.use(express.session({ secret: keyboard cat, store: new RedisStore}));app.get(/, function(req, res){ res.send(hello world);});app.listen(3000);http://expressjs.com/guide.html#session-support
  22. 22. Use case #3:Pub/Sub
  23. 23. Chat ChatServer Server Load Balancer
  24. 24. Use case #4:Job Queue
  25. 25. i.e.:Image resize API
  26. 26. 1) Download image 2) Resize image with GD Node ServerGET /image_resize?url=http://...
  27. 27. orker Job Resize Queue Workers1) Download image Node2) Resize image with GD Server GET /image_resize?url=http://...
  28. 28. Kuehttps://github.com/learnboost/kue
  29. 29. Theres a lot more! 11 Common Web Use Cases Solved in Redis http://bit.ly/pgDmXn
  30. 30. Questions? :)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×