What are other Redis commands?

Redis offers a wide range of commands to manage data effectively. Here are some commonly used Redis commands categorized by their functionality:

1. String Commands

  • SET: Store a string value under a key.
    SET key "value"
  • GET: Retrieve the value associated with a key.
    GET key
  • DEL: Delete a key and its associated value.
    DEL key

2. Hash Commands

  • HSET: Set the value of a field in a hash.
    HSET myhash field1 "value1"
  • HGET: Get the value of a field in a hash.
    HGET myhash field1
  • HDEL: Delete a field from a hash.
    HDEL myhash field1

3. List Commands

  • LPUSH: Add one or multiple elements to the beginning of a list.
    LPUSH mylist "value1"
  • LRANGE: Get a range of elements from a list.
    LRANGE mylist 0 -1  # Get all elements
  • LPOP: Remove and return the first element of a list.
    LPOP mylist

4. Set Commands

  • SADD: Add one or more members to a set.
    SADD myset "value1"
  • SMEMBERS: Get all the members of a set.
    SMEMBERS myset
  • SREM: Remove one or more members from a set.
    SREM myset "value1"

5. Sorted Set Commands

  • ZADD: Add a member with a score to a sorted set.
    ZADD mysortedset 1 "value1"
  • ZRANGE: Get a range of members from a sorted set by index.
    ZRANGE mysortedset 0 -1
  • ZREM: Remove a member from a sorted set.
    ZREM mysortedset "value1"

6. Key Commands

  • KEYS: Find all keys matching a pattern (use with caution in production).
    KEYS *
  • EXISTS: Check if a key exists.
    EXISTS key

7. Transaction Commands

  • MULTI: Start a transaction.
    MULTI
  • EXEC: Execute all commands issued after MULTI.
    EXEC

8. Server Commands

  • INFO: Get information and statistics about the server.
    INFO
  • FLUSHALL: Remove all keys from all databases.
    FLUSHALL

Further Learning

To explore more Redis commands and their usage, you can refer to the Redis Command Documentation. Additionally, practicing these commands in a LabEx lab can help solidify your understanding.

If you have any specific commands you want to know more about or need further clarification, feel free to ask! Your feedback is always welcome.

0 Comments

no data
Be the first to share your comment!