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

Redis for fun and profit

mattg
August 25, 2012

Redis for fun and profit

A simple overview of redis

mattg

August 25, 2012
Tweet

More Decks by mattg

Other Decks in Technology

Transcript

  1. Redis is not ... a replacement for your database. or

    necessarily fault tolerant. Saturday, August 25, 12
  2. if you... need key value store that’s very fast. have

    a dataset that can fit into ram. are ok if not everything survives. Redis is very interesting! Saturday, August 25, 12
  3. String Basics SET key value GET key SETEX key seconds

    value APPEND key value Saturday, August 25, 12
  4. redis>get hello (nil) redis> set hello world OK redis>get hello

    “world” String Basics Saturday, August 25, 12
  5. String Basics redis>incr stat1 1 redis> incrby stat1 2 3

    redis> decr stat1 2 redis> get stat1 2 Saturday, August 25, 12
  6. Lists LPUSH key value (B)LPOP key LRANGE key start stop

    LLEN key LSET key index value LINDEX key index Saturday, August 25, 12
  7. Sets SADD key member SREM key member SISMEMBER key member

    SMEMBERS key SCARD key Saturday, August 25, 12
  8. Hashes HSET key field value HDEL key field HKEYS keys

    HLEN key HGETALL key Saturday, August 25, 12
  9. Other Interesting Commands KEYS pattern DEL key RENAME key newkey

    EXISTS key EXPIRE key PERSIST key Saturday, August 25, 12
  10. Server Commands redis> BGREWRITEAOF redis> BGSAVE redis> DBSIZE redis> INFO

    redis> FLUSHALL redis> SLAVEOF host port Saturday, August 25, 12
  11. Benchmarks SET: 47709.93 requests per second GET: 49900.20 requests per

    second INCR: 47801.15 requests per second LPUSH: 49188.39 requests per second LPOP: 48355.90 requests per second SADD: 46970.41 requests per second SPOP: 50581.69 requests per second LPUSH: 47755.49 requests per second Saturday, August 25, 12