设置指定key的value。如果key已经存在,则覆盖原来的value。
void set(const char *key, const char *value);获取指定key的value。
const char *get(const char *key);删除指定的key。
int del(const char *key);为key设置过期时间,单位为秒。
int expire(const char *key, int seconds);获取key的剩余过期时间,单位为秒。
long long ttl(const char *key);检查key是否存在。
int exists(const char *key);将key的value增加1。
long long incr(const char *key);将key的value减1。
long long decr(const char *key);同时设置一个或多个key-value对。
void mset(const char **keys, const char **values, int count);同时获取一个或多个key的value。
void mget(const char **keys, void *values, int count);获取所有活跃的Redis节点的列表。
int mping(const char **hosts, int count);当key不存在时,设置key的value。
int setnx(const char *key, const char *value);获取key的当前value,并设置新的value。
const char *getset(const char *key, const char *value);获取key在指定偏移量处的位值。
unsigned char getbit(const char *key, long long offset);设置key在指定偏移量处的位值。
void setbit(const char *key, long long offset, unsigned char value);计算key中指定范围内的位值为1的数量。
long long bitcount(const char *key, long long start, long long end);对多个key执行位运算。
void bitop(char op, const char *destkey, const char *key, int count);为哈希表key设置field的value。
void hset(const char *key, const char *field, const char *value);获取哈希表key中field的value。
const char *hget(const char *key, const char *field);获取哈希表key中所有field-value对。
void hgetall(const char *key, dictEntry **dict);删除哈希表key中的一个或多个field。
int hdel(const char *key, const char *field, int count);获取哈希表key中field的数量。
long long hlen(const char *key);获取哈希表key中所有field的值。
void hkeys(const char *key, dictEntry **dict);获取哈希表key中所有value的值。
void hvals(const char *key, dictEntry **dict);从source列表中弹出一个元素,并将其推入destination列表的末尾。
void rpoplpush(const char *source, const char *destination);将一个或多个value元素添加到列表key的表头。
void lpush(const char *key, const char *value, int count);从列表key的表头弹出一个元素。
const char *lpop(const char *key);获取列表key中从start到end的元素。
void lrange(const char *key, long long start, long long end, void *values, int count);获取列表key中index位置的元素。
const char *lindex(const char *key, long long index);从列表key中移除count个值为value的元素。
int lrem(const char *key, int count, const char *value);这些是Redis中最常用的30个核心接口。通过这些接口,你可以实现各种复杂的业务场景,如缓存、消息队列、计数器等。