-
Notifications
You must be signed in to change notification settings - Fork 5
Redis (Basics)
Gaurav Chandak edited this page Jul 23, 2016
·
1 revision
#Redis (Basics)
Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. Redis is written in C.
Redis has three main peculiarities that set it apart from much of its competition:
- Redis holds its database entirely in memory, using the disk only for persistence.
- Redis has a relatively rich set of data types when compared to many keyvalue data stores.
- Redis can replicate data to any number of slaves.
Redis transactions allow the execution of a group of commands in a single step. Transactions has two properties in it, which are described below:
- All commands in a transaction are sequentially executed as a single isolated operation. It is not possible that a request issued by another client is served in the middle of the execution of a Redis transaction.
- Redis transaction is also atomic. Atomic means either all of the commands or none are processed.
Partitioning is the process of splitting your data into multiple Redis instances, so that every instance will only contain a subset of your keys.
set name gaurav
get name
mset tmp abc tmp1 bcd
mget tmp tmp1
del name
exists name
keys *
keys *name
expire name 2
ttl name
strlen name
incr num
append name chandak
hset gc name gaurav
hget gc name
hmset gc name gaurav surname chandak
hgetall gc
hkeys gc
hvals gc
hlen gc
hexists gc name
lpush list1 gaurav
rpush list1 chandak
lrange list1 2 10
llen list1
lpop list1
rpop list1
lindex list1 1
lrem list1 -2 "gaurav"
sadd tutorials redis mongodb mongodb
smembers tutorials
sismember tutorials redis
scard tutorials
sinter tutorials tutorials1
spop tutorials
srem tutorials mongodb
zadd tutorials 1 redis 2 mongodb 3 mongodb
zrange tutorials 0 10 withscores
zrangebyscore tutorials 0 100
pfadd tutorials "redis" tutorials "mongodb"
pfcount tutorials
subscribe redischat
publish redischat "redis is a great caching technique"