Redis: Strings Cheat Sheet

Set Command

redis 127.0.0.1:6379> SET KEY_NAME VALUE

Get Command

redis 127.0.0.1:6379> GET KEY_NAME

Getrange Command

redis 127.0.0.1:6379> GETRANGE KEY_NAME start end

Getset Command

redis 127.0.0.1:6379> GETSET KEY_NAME VALUE

Getbit Command

redis 127.0.0.1:6379> GETBIT KEY_NAME OFFSET

Mget Command

redis 127.0.0.1:6379> MGET KEY1 KEY2 .. KEYN

Setbit Command

redis 127.0.0.1:6379> SETBIT KEY_NAME OFFSET

Setex Command

redis 127.0.0.1:6379> SETEX KEY_NAME TIMEOUT VALUE

Setnx Command

redis 127.0.0.1:6379> SETNX KEY_NAME VALUE

Setrange Command

redis 127.0.0.1:6379> SETRANGE KEY_NAME OFFSET VALUE

Strlen Command

redis 127.0.0.1:6379> STRLEN KEY_NAME 

Mset Command

redis 127.0.0.1:6379> MSET key1 value1 key2 value2 .. keyN valueN

Msetnx Command

redis 127.0.0.1:6379> MSETNX key1 value1 key2 value2 .. keyN valueN 

Psetex Command

redis 127.0.0.1:6379> PSETEX key1 EXPIRY_IN_MILLISECONDS value1

Incr Command

redis 127.0.0.1:6379> INCR KEY_NAME

Incrby Command

redis 127.0.0.1:6379> INCRBY KEY_NAME INCR_AMOUNT

Incrbyfloat Command

redis 127.0.0.1:6379> INCRBYFLOAT KEY_NAME INCR_AMOUNT 

Decr Command

redis 127.0.0.1:6379> DECR KEY_NAME

Decrby Command

redis 127.0.0.1:6379> DECRBY KEY_NAME DECREMENT_AMOUNT

Append Command

redis 127.0.0.1:6379> APPEND KEY_NAME NEW_VALUE

Leave a Reply

Your email address will not be published. Required fields are marked *