Getting Started with Redis

87
GETTING STARTED WITH REDIS INTRODUCTION TO REDIS Created by Daniel Ku

description

Redis(http://redis.io/)는 최근 눈부시게 성장하고 있는 Key-Value Store 형태의 NoSQL이다. Redis **시작하기**인 만큼 많이 사용되는 명령어들을 위주로 살펴보았다.

Transcript of Getting Started with Redis

Page 1: Getting Started with Redis

GETTING STARTED WITH

REDISINTRODUCTION TO REDIS

Created by Daniel Ku

Page 2: Getting Started with Redis

REDIS is an open source, BSD licensed,advanced key-value store.

Redis

Page 3: Getting Started with Redis

FEATURES Data Types

Publish/SubscribeReplication *Persistence *

(Various)

Page 4: Getting Started with Redis

INSTALLATION ON MAC$ brew install redis

Thanks, .brew

Page 5: Getting Started with Redis

OTHER PLATFORMS ?.Download

Page 6: Getting Started with Redis

START SERVER$ redis-server /usr/local/etc/redis.conf

Page 7: Getting Started with Redis

START SERVER AT LOGIN ON MAC$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

Page 8: Getting Started with Redis

START SHELL CLIENT$ redis-cli127.0.0.1:6379>

Page 9: Getting Started with Redis

CONNECTION COMMANDSPINGECHO messageQUIT

127.0.0.1:6379> pingPONG127.0.0.1:6379> echo hello"hello"127.0.0.1:6379> quit

Page 10: Getting Started with Redis

DATABASE COMMANDSSELECT index

127.0.0.1:6379> select 1OK127.0.0.1:6379[1]> select 15OK127.0.0.1:6379[15]> select 16 // error(error) ERR invalid DB index127.0.0.1:6379[16]> select 0OK

Page 11: Getting Started with Redis

DATABASESBy default, there are 16 databases.

By default, selects database 0.

Page 12: Getting Started with Redis

STRING COMMANDS

Page 13: Getting Started with Redis

SET key valueGET key

127.0.0.1:6379> set name "Daniel"OK127.0.0.1:6379> get name"Daniel"

Page 14: Getting Started with Redis

APPEND key valueSTRLEN key

127.0.0.1:6379> get name"Daniel"127.0.0.1:6379> append name " Ku"(integer) 9127.0.0.1:6379> get name"Daniel Ku"127.0.0.1:6379> strlen name(integer) 9

Page 15: Getting Started with Redis

GETRANGE key start endSETRANGE key offset value

127.0.0.1:6379> get name"Daniel Ku"127.0.0.1:6379> getrange name 4 7"el K"127.0.0.1:6379> setrange name 7 Kim(integer) 10127.0.0.1:6379> get name"Daniel Kim"

Page 16: Getting Started with Redis

GETSET key value

127.0.0.1:6379> get name"Daniel Kim"127.0.0.1:6379> getset name "Jenny Lee""Daniel Kim"127.0.0.1:6379> get name"Jenny Lee"

Page 17: Getting Started with Redis

MSET key value [key value ...]MGET key [key ...]

127.0.0.1:6379> mset name1 "Daniel Ku" name2 "Jenny Lee"OK127.0.0.1:6379> mget name1 name21) "Daniel Ku"2) "Jenny Lee"

M- = Multiple

Page 18: Getting Started with Redis

INCR keyDECR key

127.0.0.1:6379> set age 30OK127.0.0.1:6379> get age"30"127.0.0.1:6379> incr age(integer) 31127.0.0.1:6379> get age"31"127.0.0.1:6379> decr age(integer) 30127.0.0.1:6379> get age"30"

Page 19: Getting Started with Redis

INCRBY key incrementDECRBY key decrement

127.0.0.1:6379> get age"30"127.0.0.1:6379> incrby age 10(integer) 40127.0.0.1:6379> incrby age 10(integer) 50127.0.0.1:6379> decrby age 10(integer) 40127.0.0.1:6379> get age"40"

Page 20: Getting Started with Redis

INCRBYFLOAT key increment

127.0.0.1:6379> get age"40"127.0.0.1:6379> incrby age 1.5(error) ERR value is not an integer or out of range127.0.0.1:6379> incrbyfloat age 1.5"41.5"127.0.0.1:6379> get age"41.5"127.0.0.1:6379> incr age(error) ERR value is not an integer or out of range

Page 21: Getting Started with Redis

SETEX key seconds valuePSETEX key millis value

127.0.0.1:6379> get name"Jenny Lee"127.0.0.1:6379> setex name 5 "Daniel Ku"OK127.0.0.1:6379> get name"Daniel Ku"127.0.0.1:6379> get name // after 5 seconds(nil)127.0.0.1:6379> psetex name 5000 "Daniel Ku"OK127.0.0.1:6379> get name"Daniel Ku"127.0.0.1:6379> get name // after 5000 milliseconds(nil)

-EX = EXpire

Page 22: Getting Started with Redis

SETNX key value

127.0.0.1:6379> get name(nil)127.0.0.1:6379> setnx name "Daniel Ku"(integer) 1127.0.0.1:6379> get name"Daniel Ku"127.0.0.1:6379> setnx name "Jenny Lee"(integer) 0127.0.0.1:6379> get name"Daniel Ku"

-NX = Not eXist

Page 23: Getting Started with Redis

MSETNX key value [key value ...]

127.0.0.1:6379> msetnx x 1 y 2(integer) 1127.0.0.1:6379> mget x y1) "1"2) "2"127.0.0.1:6379> msetnx x 3 z 4(integer) 0127.0.0.1:6379> mget x y z1) "1"2) "2"3) (nil)

Page 24: Getting Started with Redis

LIST COMMANDS

Page 25: Getting Started with Redis

LPUSH key value [value ...]LRANGE key start stop

127.0.0.1:6379> lpush list a b c(integer) 3127.0.0.1:6379> lrange list 0 -11) "c"2) "b"3) "a"127.0.0.1:6379> lpush list d(integer) 4127.0.0.1:6379> lrange list 0 -11) "d"2) "c"3) "b"4) "a"127.0.0.1:6379> lrange list 2 31) "b"2) "a"

L- = List & Left

Page 26: Getting Started with Redis

RPUSH key value [value ...]

127.0.0.1:6379> lrange list 0 -11) "d"2) "c"3) "b"4) "a"127.0.0.1:6379> rpush list z(integer) 5127.0.0.1:6379> lrange list 0 -11) "d"2) "c"3) "b"4) "a"5) "z"

R- = Right

Page 27: Getting Started with Redis

LPOP keyRPOP keyLLEN key

127.0.0.1:6379> lpop list"d"127.0.0.1:6379> lrange list 0 -11) "c"2) "b"3) "a"4) "z"127.0.0.1:6379> rpop list"z"127.0.0.1:6379> lrange list 0 -11) "c"2) "b"3) "a"127.0.0.1:6379> llen list(integer) 3

Page 28: Getting Started with Redis

LREM key count value

127.0.0.1:6379> lrange list 0 -11) "c"2) "b"3) "a"127.0.0.1:6379> lrem list 1 a(integer) 1127.0.0.1:6379> lrange list 0 -11) "c"2) "b"127.0.0.1:6379> lrem list 1 a(integer) 0127.0.0.1:6379> lrange list 0 -11) "c"2) "b"

Page 29: Getting Started with Redis

127.0.0.1:6379> lpush list c b a b(integer) 6127.0.0.1:6379> lrange list 0 -11) "b"2) "a"3) "b"4) "c"5) "c"6) "b"127.0.0.1:6379> lrem list 2 b(integer) 2127.0.0.1:6379> lrange list 0 -11) "a"2) "c"3) "c"4) "b"

Page 30: Getting Started with Redis

127.0.0.1:6379> lpush list c(integer) 5127.0.0.1:6379> lrange list 0 -11) "c"2) "a"3) "c"4) "c"5) "b"127.0.0.1:6379> lrem list -2 c(integer) 2127.0.0.1:6379> lrange list 0 -11) "c"2) "a"3) "b"

Page 31: Getting Started with Redis

LINSERT key BEFORE|AFTER pivot value

127.0.0.1:6379> lrange list 0 -11) "c"2) "a"3) "b"127.0.0.1:6379> linsert list before a x(integer) 4127.0.0.1:6379> lrange list 0 -11) "c"2) "x"3) "a"4) "b"

Page 32: Getting Started with Redis

127.0.0.1:6379> linsert list after a y(integer) 5127.0.0.1:6379> lrange list 0 -11) "c"2) "x"3) "a"4) "y"5) "b"

Page 33: Getting Started with Redis

LINDEX key index

127.0.0.1:6379> lrange list 0 -11) "c"2) "x"3) "a"4) "y"5) "b"127.0.0.1:6379> lindex list 0"c"127.0.0.1:6379> lindex list -1"b"127.0.0.1:6379> lindex list 3"y"

Page 34: Getting Started with Redis

LSET key index value

127.0.0.1:6379> lrange list 0 -11) "c"2) "x"3) "a"4) "y"5) "b"127.0.0.1:6379> lset list 1 XOK127.0.0.1:6379> lrange list 0 -11) "c"2) "X"3) "a"4) "y"5) "b"

Page 35: Getting Started with Redis

LTRIM key start stop

127.0.0.1:6379> lrange list 0 -11) "c"2) "X"3) "a"4) "y"5) "b"127.0.0.1:6379> ltrim list 2 3OK127.0.0.1:6379> lrange list 0 -11) "a"2) "y"

Page 36: Getting Started with Redis

RPOPLPUSH source destination

127.0.0.1:6379> lrange list 0 -11) "a"2) "y"127.0.0.1:6379> rpoplpush list list2"y"127.0.0.1:6379> lrange list 0 -11) "a"127.0.0.1:6379> lrange list2 0 -11) "y"127.0.0.1:6379> rpoplpush list list2"a"127.0.0.1:6379> lrange list 0 -1(empty list or set)127.0.0.1:6379> lrange list2 0 -11) "a"2) "y"

Page 37: Getting Started with Redis

LPUSHX key valueRPUSHX key value

127.0.0.1:6379> lrange list 0 -1(empty list or set)127.0.0.1:6379> lrange list2 0 -11) "a"2) "y"127.0.0.1:6379> lpushx list a(integer) 0127.0.0.1:6379> lrange list 0 -1(empty list or set)127.0.0.1:6379> lpushx list2 b(integer) 3127.0.0.1:6379> lrange list2 0 -11) "b"2) "a"3) "y"

-X = eXist

Page 38: Getting Started with Redis

BLPOP key [key ...] timeoutBRPOP key [key ...] timeout

Client #1127.0.0.1:6379> lrange names 0 -1(empty list or set)127.0.0.1:6379> lpush names daniel(integer) 1127.0.0.1:6379> lrange names 0 -11) "daniel"

Client #2127.0.0.1:6379> blpop names 11) "names"2) "daniel"

Client #1127.0.0.1:6379> lrange names 0 -1(empty list or set)

B- = Blocking

Page 39: Getting Started with Redis

Client #1127.0.0.1:6379> blpop names 5 // wait for 5 seconds(nil)(5.24s)127.0.0.1:6379> blpop names 5

Client #2127.0.0.1:6379> lpush names daniel(integer) 1

Client #11) "names"2) "daniel"(2.47s)

Page 40: Getting Started with Redis

Client #1127.0.0.1:6379> blpop names names2 5

Client #2127.0.0.1:6379> lpush names2 daniel(integer) 1

Client #11) "names2"2) "daniel"(3.18s)

Page 41: Getting Started with Redis

BRPOPLPUSH source destination timeout

Client #1127.0.0.1:6379> lrange names 0 -1(empty list or set)127.0.0.1:6379> lrange names2 0 -1(empty list or set)127.0.0.1:6379> brpoplpush names names2 5

Client #2127.0.0.1:6379> lpush names daniel(integer) 1

Client #1"daniel"(2.03s)127.0.0.1:6379> lrange names 0 -1(empty list or set)127.0.0.1:6379> lrange names2 0 -11) "daniel"

Page 42: Getting Started with Redis

HASH COMMANDS

Page 43: Getting Started with Redis

HSET key field valueHGET key fieldHGETALL key

127.0.0.1:6379> hset object name daniel(integer) 1127.0.0.1:6379> hset object age 34(integer) 1127.0.0.1:6379> hget object name"daniel"127.0.0.1:6379> hget object age"34"127.0.0.1:6379> hgetall object1) "name"2) "daniel"3) "age"4) "34"

H- = Hash

Page 44: Getting Started with Redis

HKEYS keyHVALS keyHEXISTS key fieldHLEN key

127.0.0.1:6379> hkeys object1) "name"2) "age"127.0.0.1:6379> hvals object1) "daniel"2) "34"127.0.0.1:6379> hexists object name(integer) 1127.0.0.1:6379> hexists object job(integer) 0127.0.0.1:6379> hlen object(integer) 2

Page 45: Getting Started with Redis

HINCRBY key field incrementHINCRBYFLOAT key field increment

127.0.0.1:6379> hincrby object age 1(integer) 35127.0.0.1:6379> hincrby object age -2(integer) 33127.0.0.1:6379> hgetall object1) "name"2) "daniel"3) "age"4) "33"

Page 46: Getting Started with Redis

HMSET key field value [field value ...]HMGET key field [field ...]

127.0.0.1:6379> hmset object2 f1 x f2 yOK127.0.0.1:6379> hmget object2 f1 f21) "x"2) "y"127.0.0.1:6379> hgetall object21) "f1"2) "x"3) "f2"4) "y"

Page 47: Getting Started with Redis

HSETNX key field value

127.0.0.1:6379> hsetnx object2 f3 z(integer) 1127.0.0.1:6379> hsetnx object2 f3 Z(integer) 0127.0.0.1:6379> hgetall object21) "f1"2) "x"3) "f2"4) "y"5) "f3"6) "z"

Page 48: Getting Started with Redis

HDEL key field [field ...]

127.0.0.1:6379> hdel object2 f3(integer) 1127.0.0.1:6379> hdel object2 f2(integer) 1127.0.0.1:6379> hgetall object21) "f1"2) "x"

Page 49: Getting Started with Redis

SET COMMANDS

Page 50: Getting Started with Redis

SADD key member [member ...]SMEMBERS key

127.0.0.1:6379> sadd set one(integer) 1127.0.0.1:6379> sadd set two three(integer) 2127.0.0.1:6379> smembers set1) "one"2) "three"3) "two"

S- = Set

Page 51: Getting Started with Redis

SREM key member [member ...]SISMEMBER key memberSCARD key

127.0.0.1:6379> srem set three(integer) 1127.0.0.1:6379> smembers set1) "one"2) "two"127.0.0.1:6379> sismember set one(integer) 1127.0.0.1:6379> sismember set three(integer) 0127.0.0.1:6379> scard set(integer) 2

Page 52: Getting Started with Redis

SRANDMEMBER key

127.0.0.1:6379> sadd set three(integer) 1127.0.0.1:6379> smembers set1) "one"2) "three"3) "two"127.0.0.1:6379> srandmember set"two"127.0.0.1:6379> srandmember set"one"127.0.0.1:6379> srandmember set"two"127.0.0.1:6379> srandmember set"two"127.0.0.1:6379> srandmember set"three"

Page 53: Getting Started with Redis

SPOP key

127.0.0.1:6379> spop set"one"127.0.0.1:6379> spop set"three"127.0.0.1:6379> smembers set1) "two"127.0.0.1:6379> spop set"two"127.0.0.1:6379> smembers set(empty list or set)

Page 54: Getting Started with Redis

SDIFF key [key ...]SDIFFSTORE destination key [key ...]

127.0.0.1:6379> sadd set1 one two three(integer) 3127.0.0.1:6379> sadd set2 one two four five(integer) 4127.0.0.1:6379> sdiff set1 set21) "three"127.0.0.1:6379> sdiff set2 set11) "four"2) "five"127.0.0.1:6379> sdiffstore set3 set1 set2(integer) 1127.0.0.1:6379> smembers set31) "three"

Page 55: Getting Started with Redis

SINTER key [key ...]SINTERSTORE destination key [key ...]SUNION key [key ...]SUNIONSTORE destination key [key ...]

127.0.0.1:6379> sinter set1 set21) "one"2) "two"127.0.0.1:6379> sunion set1 set21) "two"2) "one"3) "four"4) "five"5) "three"

Page 56: Getting Started with Redis

SMOVE source destination member

127.0.0.1:6379> smove set1 set2 three(integer) 1127.0.0.1:6379> smembers set11) "one"2) "two"127.0.0.1:6379> smembers set21) "four"2) "one"3) "five"4) "two"5) "three"

Page 57: Getting Started with Redis

SORTED SET COMMANDS

Page 58: Getting Started with Redis

ZADD key score member [score member ...]ZCARD key

127.0.0.1:6379> zadd zset 10 one(integer) 1127.0.0.1:6379> zadd zset 20 two 30 three(integer) 2127.0.0.1:6379> zcard zset(integer) 3

Z- = Sorted Set

Page 59: Getting Started with Redis

ZSCORE key memberZCOUNT key min max

127.0.0.1:6379> zscore zset one"10"127.0.0.1:6379> zscore zset two"20"127.0.0.1:6379> zcount zset -inf +inf(integer) 3127.0.0.1:6379> zcount zset 10 20(integer) 2127.0.0.1:6379> zcount zset 10 (20(integer) 1

Z- = Sorted Set

Page 60: Getting Started with Redis

ZRANK key memberZREVRANK key member

127.0.0.1:6379> zrank zset one(integer) 0127.0.0.1:6379> zrank zset three(integer) 2127.0.0.1:6379> zrevrank zset one(integer) 2127.0.0.1:6379> zrevrank zset three(integer) 0

Page 61: Getting Started with Redis

ZRANGE key start stop [WITHSCORES]ZREVRANGE key start stop [WITHSCORES]

127.0.0.1:6379> zrange zset 0 -11) "one"2) "two"3) "three"127.0.0.1:6379> zrange zset 0 -1 withscores1) "one"2) "10"3) "two"4) "20"5) "three"6) "30"127.0.0.1:6379> zrevrange zset 0 1 withscores1) "three"2) "30"3) "two"4) "20"

Page 62: Getting Started with Redis

ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]ZREVRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]

127.0.0.1:6379> zrangebyscore zset 20 301) "two"2) "three"127.0.0.1:6379> zrangebyscore zset (20 30 withscores1) "three"2) "30"127.0.0.1:6379> zrevrangebyscore zset 30 (10 withscores1) "three"2) "30"3) "two"4) "20"127.0.0.1:6379> zrevrangebyscore zset +inf -inf withscores limit 2 11) "one"2) "10"

Page 63: Getting Started with Redis

ZINCRBY key increment memberZREM key member [member ...]

127.0.0.1:6379> zincrby zset 5 two"25"127.0.0.1:6379> zscore zset two"25"127.0.0.1:6379> zrem zset three(integer) 1127.0.0.1:6379> zrange zset 0 -1 withscores1) "one"2) "10"3) "two"4) "25"

Page 64: Getting Started with Redis

ZREMRANGEBYSCORE key min maxZREMRANGEBYRANK key min max

127.0.0.1:6379> zremrangebyscore zset 10 20(integer) 1127.0.0.1:6379> zrange zset 0 -1 withscores1) "two"2) "25"127.0.0.1:6379> zremrangebyrank zset 0 -1(integer) 1127.0.0.1:6379> zrange zset 0 -1 withscores(empty list or set)

Page 65: Getting Started with Redis

KEYS COMMANDS

Page 66: Getting Started with Redis

KEYS patten

127.0.0.1:6379> keys * 1) "set2" 2) "set3" 3) "object2" 4) "name1" 5) "x" 6) "object" 7) "age" 8) "list2" 9) "name2"10) "name"11) "y"12) "set1"13) "names2"

127.0.0.1:6379> keys name*1) "name1"2) "name2"3) "name"4) "names2"127.0.0.1:6379> keys set*1) "set2"2) "set3"3) "set1"

Page 67: Getting Started with Redis

EXISTS keyTYPE key

127.0.0.1:6379> exists name(integer) 1127.0.0.1:6379> exists set(integer) 0127.0.0.1:6379> type namestring127.0.0.1:6379> type agestring127.0.0.1:6379> type set1set127.0.0.1:6379> type list2list

Page 68: Getting Started with Redis

DEL key [key ...]

127.0.0.1:6379> del x y(integer) 2127.0.0.1:6379> keys * 1) "set2" 2) "set3" 3) "object2" 4) "list" 5) "name1" 6) "object" 7) "age" 8) "name2" 9) "name"10) "set1"11) "names2"

Page 69: Getting Started with Redis

RENAME key newkeyRENAMENX key newkey

127.0.0.1:6379> keys list*1) "list2"127.0.0.1:6379> rename list2 listOK127.0.0.1:6379> keys list*1) "list"

127.0.0.1:6379> keys name*1) "name1"2) "names2"3) "name2"4) "name"127.0.0.1:6379> renamenx name2 name(integer) 0127.0.0.1:6379> renamenx names2 names(integer) 1127.0.0.1:6379> keys name*1) "name1"2) "names"3) "name2"4) "name"

Page 70: Getting Started with Redis

MOVE key db

127.0.0.1:6379> keys name*1) "name1"2) "names"3) "name2"4) "name"127.0.0.1:6379> move name 1(integer) 1127.0.0.1:6379> keys name*1) "name1"2) "names"3) "name2"127.0.0.1:6379> select 1OK127.0.0.1:6379[1]> keys name*1) "name"127.0.0.1:6379[1]> select 0OK

Page 71: Getting Started with Redis

RANDOMKEY

127.0.0.1:6379> randomkey"set2"127.0.0.1:6379> randomkey"name1"127.0.0.1:6379> randomkey"list"127.0.0.1:6379> randomkey"name2"127.0.0.1:6379> randomkey"age"127.0.0.1:6379> randomkey"object2"127.0.0.1:6379> randomkey"set1"

Page 72: Getting Started with Redis

EXPIRE key secondsPEXPIRE key millisEXPIREAT key timestampPEXPIREAT key millis-timestamp

127.0.0.1:6379> expire name1 5(integer) 1127.0.0.1:6379> get name1"Daniel Ku"127.0.0.1:6379> get name1 // after 5 seconds(nil)127.0.0.1:6379> pexpire name2 5000(integer) 1127.0.0.1:6379> get name2"Jenny Lee"127.0.0.1:6379> get name2 // after 5000 seconds(nil)

Page 73: Getting Started with Redis

TTL keyPTTL key

127.0.0.1:6379> set age 34OK127.0.0.1:6379> ttl age(integer) -1127.0.0.1:6379> expire age 5(integer) 1127.0.0.1:6379> ttl age(integer) 4127.0.0.1:6379> pttl age(integer) 1720127.0.0.1:6379> ttl age(integer) -2

Page 74: Getting Started with Redis

PERSIST key

127.0.0.1:6379> set name DanielOK127.0.0.1:6379> expire name 5(integer) 1127.0.0.1:6379> ttl name(integer) 3127.0.0.1:6379> persist name(integer) 1127.0.0.1:6379> ttl name(integer) -1127.0.0.1:6379> get name"Daniel"

Page 75: Getting Started with Redis

PUBLISH/SUBSCRIBE COMMANDS

Page 76: Getting Started with Redis

PUBLISH channel messageSUBSCRIBE channel [channel ...]

Client #1127.0.0.1:6379> subscribe channel1Reading messages... (press Ctrl-C to quit)1) "subscribe"2) "channel1"3) (integer) 1

Client #2127.0.0.1:6379> publish channel1 "Hello"(integer) 1

Client #11) "message"2) "channel1"3) "Hello"

Page 77: Getting Started with Redis

PSUBSCRIBE pattern [pattern ...]

Client #1127.0.0.1:6379> psubscribe channel*Reading messages... (press Ctrl-C to quit)1) "psubscribe"2) "channel*"3) (integer) 1

Client #2127.0.0.1:6379> publish channel1 Hi(integer) 2

Client #11) "pmessage"2) "channel*"3) "channel1"4) "Hi"

Client #2127.0.0.1:6379> publish channel2 Hello(integer) 2

Client #11) "pmessage"

Page 78: Getting Started with Redis

UNSUBSCRIBE [channel [channel ...]]PUNSUBSCRIBE [pattern [pattern ...]]

Not Applicable in redis-cli

Page 79: Getting Started with Redis

TRANSACTIONS COMMANDS

Page 80: Getting Started with Redis

MULTIEXEC

127.0.0.1:6379> multiOK127.0.0.1:6379> set name "Daniel"QUEUED127.0.0.1:6379> set age 20QUEUED127.0.0.1:6379> exec1) OK2) OK127.0.0.1:6379> mget name age1) "Daniel"2) "20"

Page 81: Getting Started with Redis

127.0.0.1:6379> multiOK127.0.0.1:6379> incr nameQUEUED127.0.0.1:6379> incr ageQUEUED127.0.0.1:6379> exec1) (error) ERR value is not an integer or out of range2) (integer) 21127.0.0.1:6379> mget name age1) "Daniel"2) "21"

Page 82: Getting Started with Redis

DISCARD

127.0.0.1:6379> multiOK127.0.0.1:6379> set name "Daniel"QUEUED127.0.0.1:6379> set age 30QUEUED127.0.0.1:6379> discardOK

Page 83: Getting Started with Redis

NODE.JS DRIVER FOR REDIShttps://github.com/mranney/node_redis

$ npm install hiredis redis

Page 84: Getting Started with Redis

SOCKET.IOhttp://socket.io/

$ npm install socket.io$ bower install socket.io-client

Page 85: Getting Started with Redis

EXAMPLEhttps://github.com/kjunine/redis-samples

Page 86: Getting Started with Redis

REFERENCESTuts+ Premium: Redis Essential�용량 서버 구축을 위한 Memcached와 Redis11 Common Web Use Cases Solved In Redis

Page 87: Getting Started with Redis

THE ENDTHANKS.