$ ./redis-cli -h 192.168.228.174 表示连接 192.168.228.174的redis服务器
查看redis信息: info
ping服务器: ping
退出客户端: quit
事务:
MULTI : 开启事物
* some redis command *
EXEC. : 执行事物
DISCARD :取消事物
WATCH : 监视key ,如果在事务执行之前 key 被其他命令所改动,那么事务将被打断
判断Key 是否存在 : exists key
查看所有的keys : keys * // *通配符 s*表示s开头的key,区分大小写
判断Key的类型 : type key
清空所有数据库:flushall
清空当前数据库:flushdb //
设置主从库: slaveof 192.168.228.174 6379 // 本地数据库会同步到主库
取消跟从: slaveof no noe
server:
client kill ip:port -> Kill the connection of a client
client list -> Get the list of client connections
client getname -> Get the current connection name
client set name connection-name -> Set the current connection name
time -> Return the current server time
save -> Synchronously save the dataset to disk
bgsave -> Asynchronously save the dataset to disk
lastsave -> Get the UNIX time stamp of the last successful save to disk
dbsize -> Return the number of keys in the selected database
sync -> Internal command used for replication
shutdown -> Synchronously save the dataset to disk and then shut down the server
?? monitor -> Listen for all requests received by the server in real time
config get parameter -> Get the value of a configuration parameter
config set paramater value -> Set a configuration parameter to the given value
config resetstat -> Reset the stats returned by INFO
config rewrite -> Rewrite the configuration file with the in memory configuration
debug object key -> Get debugging information about a key
debug segfault -> Make the server crash
Connection:
echo message -> Echo the given string
auth password -> Authenticate to the server
what is channel ? how publish & subscribe ?
字符串命令:
get key -> get foo
set key value -> set foo bar
append key value -> append foo bar2 如果 foo之前是bar 执行后foo成为 barbar2
strlen key -> 获取value长度
decr key -> 要求value是整数
decrby key decrement
incr key
incrby key increment
incrbyfloat key increment -> Increment the float value of a key
getset key value -> 返回旧值
mget key [key ...] -> 多个get/set
mset key value [key value ...]
getrange key start end -> getter/setter部分子串
setrange key offset value
如果key不存在,才设置value,即不会把覆盖原有的key值
setnx key value -> Set the value of a key, only if the key does not exist
msetnx key value [key value ...]
设置会过期的key
setex key seconds value -> Set the value and expiration of a key
psetex key milliseconds value -> Set the value and expiration in milliseconds of a key
比特位相关的命令:
setbit key offset value -> Sets or clears the bit at offset in the string value stored at key
getbit key offset -> Returns the bit value at offset in the string value stored at key
bitcount key [start] [end] -> Count set bits in a string
bitpos key bit [start] [end] -> Find first bit set or clear in a string
bitop and destkey key [key ...] 对一个或多个 key 求逻辑并,并将结果保存到 destkey
bitop or destkey key [key ...] 对一个或多个 key 求逻辑或,并将结果保存到 destkey
bitop xor destkey key [key ...] 对一个或多个 key 求逻辑异或,并将结果保存到 destkey
bitop not destkey key 对给定 key 求逻辑非,并将结果保存到 destkey
Hashes命令:
查看hash的所有字段: hkeys key
查看hash的所有value:hvals key
获取所有字段和值: hgetall key
查看hash有多少个字段:hlen key
判断hash的字段是否存在: hexists key field
获取hash对应字段的值:hget key field
设置hash对应字段的值:hset key field value
hmget key field [field ...]
hmset key field value [field value ...]
当不存在才设置字段的值,即不覆盖已有的值:hsetnx key field value
删除hash的字段:hdel key field [field ...]
hincrby key field increment -> Increment the integer value of a hash field
hincrbyfloat key field increment -> Increment the float value of a hash field
Lists: 列表
lpush key value [value ..] -> Prepend one or multiple values to a list
rpush key value [value ..] -> Append one or multiple values to a list
lpop key -> Remove and get the first element in a list
rpop key -> Remove and get the last element in a list
lindex key index -> Get an element from a list by its index
linsert key before|after pivot value -> Insert an element before or after another element in a list
lset key index value -> Set the value of an element in a list by its index
lrange key start stop -> Get a range of elements from a list
llen key -> Get the length of a list
lpushx key value -> Prepend a value to a list, only if the list exists
rpushx key value -> Append a value to a list, only if the list exists
rpoplpush source dest -> Remove the last element in a list, append it to another list and return it
blpop key [key ...] timeout -> Remove and get the first element in a list, or block until one is available
brpop key [key ...] timeout -> Remove and get the last element in a list, or block until one is available
brpoplpush source dest timeout -> Pop a value from a list, push it to another list and return it; or block until one is available
Sets: 集合
sadd key member [member ..] -> Add one or more members to a set
scard key -> Get the number of members in a set
smembers key -> Get all the members in a set
sismember key member -> Determine if a given value is a member of a set
spop key -> Remove and return a random member from a set
srem key member [member..] -> Remove one or more members from a set
srandmember key [count] -> Get one or multiple random members from a set
sdiff key [key ...] -> Subtract multiple sets
sinter key [key ...] ->Intersect multiple sets
sunion key [key ...] -> Add multiple sets
Sorted Sets: 有序集合
zadd key score member [score member ...] -> Add one or more members to a sorted set, or update its score if it already exists
zcard key -> Get the number of members in a sorted set
zscore key member -> Get the score associated with the given member in a sorted set
分享到:
相关推荐
redis命令全集
Redis命令实践 Redis是一个开源的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中介。由于其高性能、丰富的数据结构和简单的命令集,Redis成为了许多现代应用程序的首选。以下是对Redis命令的详细实践...
redis合集(深入了解redis,redis实践,redis适用场景及实现,redis学习笔记整理,redis命令参考手册,python简明教程.chm,redis_cmd.chm)
以下是对Redis命令实践的简介: - **基本操作**:Redis支持基本的增删改查操作,适用于字符串、列表、集合、散列和有序集合等数据类型。 - **数据结构**:Redis提供了丰富的数据结构,每种结构都有特定的命令集,...
RedisClient将redis数据以资源管理器的界面风格呈现给用户,可以帮助redis开发人员和维护人员方便的建立,修改,删除,查询redis数据,完全不需要了解redis命令。可以让用户方便的编辑数据,可以剪切,拷贝,粘贴...
Redis提供了丰富的命令集,用于管理数据、执行操作和与数据库交互。以下是一些常用的Redis基本命令: 设置键值对: SET key value:设置指定键的值 GET key:获取指定键的值 哈希表操作: HSET key field value:...
redis windon最新免安装版本,...根据用例的不同,Redis 可以通过定期将数据集转储到磁盘或将每个命令附加到基于磁盘的日志来持久化数据。如果您只是需要一个功能丰富的、联网的、内存中的缓存,也可以禁用持久性。
Redis命令用JavaScript实现的Redis命令。 **注意**这只是一个有趣的实验项目。 无论如何,我并不认为它会有用。安装$ npm install @yuanchuan/redis-commands例子var Redis = require ( '@yuanchuan/redis-commands'...
Redis 中的事务是一组命令的集合,是 Redis 的最小执行单位,一个事务要么都执行,要么都不执行。带有以下三个重要的保证: 批量操作在发送 EXEC 命令前被放入队列缓存。 收到 EXEC 命令后进入事务执行,事务中任意...
它支持多种数据类型,包括字符串(string)、哈希(hash)、列表(list)、集合(set)、有序集合(sorted set)等,并提供了丰富的命令集来操作这些数据类型。Redis支持发布/订阅(Pub/Sub)模型,允许客户端订阅...
fakeredis:redis-py的伪造版本 fakeredis是redis-py python客户端的纯Python实现,可模拟与redis服务器的通话。... 他们将redis代码库嵌入到Python中,因此他们实现了完整的redis命令集,并且其行为与真实的red
键空间通知是一种机制,允许客户端通过订阅频道或模式,来接收那些以某种方式改动了 Redis 数据集的事件。例如,所有修改键的命令、所有接收到 LPUSH 命令的键、0 号数据库中所有已过期的键等。这些事件通过 Redis ...
用到go开发的项目源码、数据集
Redis从入门到精通高清,迅雷播放器组件可顺利播放
Redis从入门到精通高清,迅雷播放器组件可顺利播放
Redis 集群是一个提供在多个Redis间节点间共享数据的程序集。 Redis集群并 不支持处理多个keys的命令,因为这需要在不同的节点间移动数据,从而达不到像Redis那样的性能,在高负载的情况下可能会导致不可预料的错误. ...
众所周知,当redis中key数量越大,keys 命令执行越慢,而且最重要的会阻塞服务器,对单线程的redis来说,简直是灾难,终于找到了替代命令scan。 SCAN cursor [MATCH pattern] [COUNT count] SCAN 命令及其相关的 ...
Redis从入门到精通高清,迅雷播放器组件可顺利播放
* 持久化(persistence):Redis 支持数据的持久化,你可以每隔一段时间将数据集转存到磁盘上(snapshot),或者在日志尾部追加每一条操作命令(append only file,aof)。 * 主从复制(master-slave replication)...
Redis是一个开源的基于内存的数据存储系统,它支持多种数据结构,如字符串、哈希、列表、集合等,并提供了丰富的命令集用于对这些数据结构进行操作。以下是Redis的安装和配置步骤: ### 1. 下载Redis 您可以从Redis...