Skip to content

Commit

Permalink
Update cheatsheets
Browse files Browse the repository at this point in the history
  • Loading branch information
LeCoupa committed Nov 18, 2017
1 parent 5c488da commit a6c5243
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
File renamed without changes.
36 changes: 18 additions & 18 deletions databases/redis.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
##############################################################################
# *****************************************************************************
# BASICS
##############################################################################
# *****************************************************************************


redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt


##############################################################################
# *****************************************************************************
# STRINGS
##############################################################################
# *****************************************************************************


APPEND key value # append a value to a key
Expand All @@ -34,10 +34,10 @@ EXPIRE key 120 # key will be deleted in 120 seconds
TTL key # returns the number of seconds until a key is deleted


##############################################################################
# *****************************************************************************
# LISTS
# A list is a series of ordered values
##############################################################################
# *****************************************************************************


RPUSH key value [value ...] # put the new value at the end of the list
Expand All @@ -56,11 +56,11 @@ BLPOP key [key ...] timeout # remove and get the first element in a li
BRPOP key [key ...] timeout # remove and get the last element in a list, or block until one is available


##############################################################################
# *****************************************************************************
# SETS
# A set is similar to a list, except it does not have a specific order
# and each element may only appear once.
##############################################################################
# *****************************************************************************


SADD key member [member ...] # add the given value to the set
Expand All @@ -74,11 +74,11 @@ SMOVE source destination member # move a member from one set to another
SPOP key [count] # remove and return one or multiple random members from a set


##############################################################################
# *****************************************************************************
# SORTED SETS
# A sorted set is similar to a regular set, but now each value has an associated score.
# This score is used to sort the elements in the set.
##############################################################################
# *****************************************************************************


ZADD key [NX|XX] [CH] [INCR] score member [score member ...] # add one or more members to a sorted set, or update its score if it already exists
Expand All @@ -96,11 +96,11 @@ ZSCORE key member # get the score associated with the given mm
ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count] # return a range of members in a sorted set, by score


##############################################################################
# *****************************************************************************
# HASHES
# Hashes are maps between string fields and string values,
# so they are the perfect data type to represent objects.
##############################################################################
# *****************************************************************************


HGET key field # get the value of a hash field
Expand All @@ -119,11 +119,11 @@ HSTRLEN key field # get the length of the value of a hash field
HVALS key # get all the values in a hash


##############################################################################
# *****************************************************************************
# HYPERLOGLOG
# HyperLogLog uses randomization in order to provide an approximation of the number
# of unique elements in a set using just a constant, and small, amount of memory
##############################################################################
# *****************************************************************************


PFADD key element [element ...] # add the specified elements to the specified HyperLogLog
Expand All @@ -132,9 +132,9 @@ PFCOUNT key [key ...] # return the approximated cardinality of the se
PFMERGE destkey sourcekey [sourcekey ...] # merge N HyperLogLogs into a single one


##############################################################################
# *****************************************************************************
# PUBLICATION & SUBSCRIPTION
##############################################################################
# *****************************************************************************


PSUBSCRIBE pattern [pattern ...] # listen for messages published to channels matching the given patterns
Expand All @@ -145,9 +145,9 @@ SUBSCRIBE channel [channel ...]  # listen for messages published to
UNSUBSCRIBE [channel [channel ...]] # stop listening for messages posted to the given channels


##############################################################################
# *****************************************************************************
# OTHER COMMANDS
##############################################################################
# *****************************************************************************


KEYS pattern # find all keys matching the given pattern

0 comments on commit a6c5243

Please sign in to comment.