Hands-On with REDIS | Part 2

Part #1 : Working with Strings.

set <KEY> <VALUE>
incr <KEY>
incrby <KEY> <VALUE_WITH_WHICH_INCREMENT_TO_BE_DONE>
decr <KEY>
decrby <KEY> <VALUE_WITH_WHICH_DECREMENT_TO_BE_DONE>
set <KEY> <VALUE>
get <KEY>
set <KEY> <VALUE>
getset <KEY> <VALUE>
mset <KEY_1> <VALUE_1> <KEY_2> <VALUE_2> <KEY_3> <VALUE_3>
  • <street, “seaward”>
  • <city, “ventura”>
  • <country, “usa”>
  • <zip, “92101–2878292”>
exists <KEY>
del <KEY>
expire <KEY> <TIME_IN_SECONDS>
set <KEY> <VALUE> ex <TIME_IN_SECONDS>

Part #2 : Working with Hash Data-Structure.

hmset <KEY> <INNER_KEY_1> <INNER_VALUE_1> <INNER_KEY_2> <INNER_VALUE_2> <INNER_KEY_3> <INNER_VALUE_3> ..
  • <firstName, “Tracey”>
  • <lastName, “Larventz”>
  • <street, “awesome”>
  • <city, “awesomer”>
hget <KEY> <INNER_KEY_1>
hmget <KEY> <INNER_KEY_1> <INNER_KEY_2>
hexists <KEY> <INNER_KEY_1>
hgetall <KEY>
hincrby <KEY> <INNER_KEY_1> <VALUE_WITH_WHICH_INCREMENT_TO_BE_DONE>

Part #3 : Working with LIST Data-Structure.

rpush <KEY> <LIST_VALUE_1> <LIST_VALUE_2> <LIST_VALUE_3> ....
  • “apples”
  • “cherries”
  • “pears”
  • “red meat”
lrange <KEY> 0 -1
lpush <KEY> <LIST_VALUE_1>
lpop <KEY>
rpop <KEY>
  • “apples”
  • “cherries”
  • “pears”
  • “red meat”
  • “cereals raisin brand”

Part #4 : Working with SET Data-Structure.

  • Set doesn’t maintains order of insertion.
  • Duplicate elements are not permissible into Set.
sadd <KEY> <SET_VALUE_1> <SET_VALUE_2> <SET_VALUE_3> ....
  • “react”
  • “react native”
  • “graphql”
  • “javascript”
smembers <KEY>
  • “framer”
  • “sketch”
sismember <KEY> <SET_VALUE_TO_BE_CHECKED_WHETHER_PRESENT>
sadd <KEY>:<SET_VALUE> <VAL_1> <VAL_2> <VAL_3> ..
smembers <KEY>:<SET_VALUE>
sunionstore <KEY>:<SET_VALUE_1> <KEY>:<SET_VALUE_2>
spop <KEY>:<SET_VALUE_1>
scard <KEY>

Part #4 : Working with SORTED-SET Data-Structure.

zadd <KEY> <INTERNAL_VAL_1> <INTERNAL_KEY_1> <INTERNAL_VAL_2> <INTERNAL_KEY_2> ..
  • <”apollo 11", 1969>
  • <”Deep space 1", 1998>
  • <”Falcon 1", 2008>
zrange <KEY> 0 -1
zrange <KEY> 0 -1 withscores
zrevrange <KEY> 0 -1 withscores
zrangebyscore <KEY> -inf <VAL_TO_BECHECKED_AGAINST> withscores
zrank <KEY> <INTERNAL_KEY>

Part #5 : Working with Publisher-Subscriber approach.

  • messages
  • news
subscribe <TOPIC_1> <TOPIC_2> ..
  • “How are you?”
  • “I’m great thank you”
publish <TOPIC_NAME> <MESSAGE>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
aditya goel

aditya goel

Software Engineer for Big Data distributed systems