Basic Redis Commands
Here are some basic Redis commands to get you started:
Key-Value Commands:
- SET: Set the string value of a key.
SET key value
- GET: Get the value of a key.
GET key
- DEL: Delete a key.
DEL key
- EXISTS: Check if a key exists.
EXISTS key
- EXPIRE: Set a timeout on a key.
EXPIRE key seconds
- TTL: Get the remaining time to live of a key.
TTL key
List Commands:
- LPUSH: Push a value onto a list from the left side.
LPUSH list value
- RPUSH: Push a value onto a list from the right side.
RPUSH list value
- LPOP: Pop a value from a list from the left side.
LPOP list
- RPOP: Pop a value from a list from the right side.
RPOP list
- LRANGE: Get a range of elements from a list.
LRANGE list start stop
Set Commands:
- SADD: Add a member to a set.
SADD set member
- SMEMBERS: Get all the members in a set.
SMEMBERS set
- SREM: Remove a member from a set.
SREM set member
- SISMEMBER: Check if a set contains a member.
SISMEMBER set member
Hash Commands:
- HSET: Set the value of a field in a hash.
HSET hash field value
- HGET: Get the value of a field in a hash.
HGET hash field
- HDEL: Delete a field from a hash.
HDEL hash field
- HGETALL: Get all the fields and values in a hash.
HGETALL hash
Sorted Set Commands:
- ZADD: Add a member to a sorted set, or update its score.
ZADD sortedSet score member
- ZRANGE: Get a range of members in a sorted set, by index.
ZRANGE sortedSet start stop
- ZREM: Remove a member from a sorted set.
ZREM sortedSet member
- ZSCORE: Get the score of a member in a sorted set.
ZSCORE sortedSet member
Miscellaneous Commands:
- PING: Test the connection to the Redis server.
PING
- INFO: Get information and statistics about the Redis server.
INFO
- FLUSHALL: Remove all keys from all databases.
FLUSHALL
These commands should give you a good start with Redis.