Skip to content

Instantly share code, notes, and snippets.

@mnadjit
Last active June 23, 2021 02:22
Show Gist options
  • Save mnadjit/36792e36fa4238bbf13698683d5bbfa8 to your computer and use it in GitHub Desktop.
Save mnadjit/36792e36fa4238bbf13698683d5bbfa8 to your computer and use it in GitHub Desktop.
Redis basic commands are listed and briefly explained in this document

REDIS Commands

Overview

  • Overview of the server
    • INFO ALL
  • Overview of memory
    • INFO MEMORY

Databases

There are 16 databases in a common Redis server: 0 to 15

  • Overview of all databases
    • INFO KEYSPACE
  • Select database 0
    • SELECT 0
  • Number of keys in current database
    • dbsize

Keys

  • Get a list of keys:
    • SCAN 0
  • Get a list of keys starting from cursor position of 0, keys matching pattern * i.e. anything, no more than 100 keys:
    • SCAN 0 MATCH * COUNT 100
  • Get keys matching a pattern:
    • e.g. KEYS <key_prefix>*
  • Check if key exists
    • EXISTS <key>
  • Get object type
    • type <key>
    • OBJECT ENCODING <key>
  • Get key's seconds remaining to expire
    • TTL <key>
  • Get key's idle time
    • OBJECT IDLETIME <key>

Hashtables

  • Get key, values or both inside a Hashtable
    • HGETALL <key>
    • HKEYS <key>
    • HVALS <key>
    • HLEN <key>
  • Get all, with definition of cursor position and count
    • HSCAN <key> 0 COUNT 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment