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

Redis

 Redis

To nie będzie kolejna prezentacja "getting started" żywcem wzięta z dokumentacji. Pokażę moc drzemiącą w tym narzędziu na prawdziwych przykładach i powiem Ci dlaczego MUSISZ zacząć korzystać z Redisa oraz dlaczego Memcached przy nim wymięka.

Sebastian Grodzicki

November 15, 2015
Tweet

More Decks by Sebastian Grodzicki

Other Decks in Programming

Transcript

  1. REDIS • strings • hashes • lists • sets •

    sorted sets • bitmaps • hyperloglogs
  2. MariaDB [goldenline]> DESCRIBE user_contact; +-------+---------+------+-----+---------+-------+ | Field | Type |

    Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | id1 | int(11) | NO | PRI | NULL | | | id2 | int(11) | NO | PRI | NULL | | +-------+---------+------+-----+---------+-------+ 2 rows in set (0.00 sec)
  3. #1.1 MEMCACHE 1. SELECT id2 FROM user_contact WHERE id1 =

    1238102 2. implode() 3. set user.contact.1238102 0 3600 3072
 100,2256,6315,6575,7663,8222,23493,43126,46317…
  4. #1.1 REDIS 1. SELECT id2 FROM user_contact WHERE id1 =

    1238102 2. SADD user.1238102.friends "100" "2256" "6315" "6575"…
  5. #1.4 MEMCACHE 1. get user.contact.1238102 2. explode() 3. array_push() 4.

    implode() 5. set user.contact.1238102 0 3600 3080
 100,2256,6315,6575,7663,8222,23493,43126,46317…
  6. #1.5 MEMCACHE 1. get user.contact.1238102 2. explode() 3. array_search() 4.

    unset() 5. implode() 6. set user.contact.1238102 0 3600 3072
 100,2256,6315,6575,7663,8222,23493,43126,46317…
  7. #4.3 REDIS 1. SETBIT 2015-11-14 1159658 1 2. SETBIT 2015-11-15

    1159658 1 3. BITTOP AND foo 2015-11-14 2015-11-15
  8. #4.3 REDIS 1. SETBIT 2015-11-14 1159658 1 2. SETBIT 2015-11-15

    1159658 1 3. BITTOP OR foo 2015-11-14 2015-11-15
  9. PIPELINING 1. Client: INCR X 2. Server: 1 3. Client:

    INCR X 4. Server: 2 5. Client: INCR X 6. Server: 3
  10. PIPELINING 1. Client: INCR X 2. Client: INCR X 3.

    Client: INCR X 4. Server: 1 5. Server: 2 6. Server: 3
  11. PIPELINING 1. Client: MULTI 2. Client: INCR X 3. Client:

    INCR X 4. Client: INCR X 5. Client: EXEC # [1,2,3]
  12. Q&A