Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Redis - little helper for big applications (rus)

Redis - little helper for big applications (rus)

Slides from my talk on sixth devclub meetup

Andrey Savchenko

February 29, 2012

Transcript

18 slides
  1. Клиенты ActionScript, C, C#, C++, Clojure, Common Lisp, Erlang, Go,

    Haskell, haXe, Io, Java, Lua, Node.js, Objective-C, Perl, PHP, Python, Ruby, Scala, Smalltalk, Tcl
  2. Cтроки SET testkey “Hello” GET testkey MSET key1 “Hello” key2

    “world” SET counter 1 INCR counter GET counter #=> “2”
  3. Xеши HSET test key1 “Hello” HSET test key2 “World” HGET

    test key2 #=> “World” HGETALL test #=> “key1” “Hello” “key2” “World”
  4. Множества SADD users “andrey” SADD users “dima” SCARD users #=>

    2 SISMEMBER users “andrey” #=> 1 SISMEMBER users “gleb” #=> 0
  5. Кеши, сессии Инвалидация по признаку SET a18b045 “cache content” SET

    d98f0c9 “cache content” SADD cond1 a18b045 SADD cond1 d98f0c9 SMEMBERS cond1 DEL {result of smembers}
  6. Хранение несвязанных (малосвязанных) данных {user_id = 1} HSET settings:1 receive_emails

    “1” HSET settings:1 records_per_page “20” HSET settings:1 preffered_syntax “markdown” HGETALL settings:1
  7. Сбор статистики {post_id=42} INCR posts:42 GET posts:42 # How many

    views/votes? ZINCRBY posts 1 42 ZSCORE posts 42 # How many views/votes? ZREVRANGE posts O 9 # TOP-10 posts ZREVRANGE posts O 9 WITHSCORES # TOP-10 with views/votes quantity
  8. Связь между демонами # Websocket server: SUBSCRIBE messages # Async

    jobs server: SUBSCRIBE jobs # Web-application: PUBLISH jobs “videos:12:mpeg:ogg” PUBLISH messages “Video encoding #12 started” # Async jobs server: PUBLISH messages “Video encoding #12 finished”
  9. Построение простых графов # User 1 adds user 5 to

    friends SADD users:1:friends 5 SADD users:5:friend_of 1 ... # Get user 5 friends SMEMBERS users:5:friends # Get user 5 mutual friends SCARD users:5:friends users:5:friend_of # Get common friens of user 5 and 7 SCARD users:5:friends users:7:friends # Are user 7 friend of user 5? SISMEMBER users:5:friends 7

More Decks by Andrey Savchenko

Other Decks in Programming