RedisKey的基本命令

HeJin大约 2 分钟数据库技术Redis

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions, and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

中文网翻译

Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中间件。 它支持多种类型的数据结构,如 字符串(strings), 散列(hashes), 列表(lists), 集合(sets), 有序集合(sorted sets) 与范围查询, bitmaps, hyperloglogs 和 地理空间(geospatial) 索引半径查询。 Redis 内置了 复制(replication),LUA脚本(Lua scripting), LRU驱动事件(LRU eviction),事务(transactions) 和不同级别的 磁盘持久化(persistence), 并通过 Redis哨兵(Sentinel)和自动 分区(Cluster)提供高可用性(high availability)。

我们现在讲解的所有命令大家一定要全部记住,后面我们使用SpringBoot。Jedis。所有的方法就是这些命令。

127.0.0.1:6379> keys *			# 查看所有的key
1) "name"
127.0.0.1:6379> set age 1		# set key
OK
127.0.0.1:6379> keys *
1) "age"
2) "name"
127.0.0.1:6379> EXISTS name		# 判断当前key是否存在
(integer) 1
127.0.0.1:6379> EXISTS name1
(integer) 0
127.0.0.1:6379> move name 1		# 移动当前的key到1号数据库
(integer) 1
127.0.0.1:6379> del age			# 移除当前key
(integer) 1
127.0.0.1:6379> set age 1
OK
127.0.0.1:6379> set name hejin
OK
127.0.0.1:6379> keys *
1) "age"
2) "name"
127.0.0.1:6379> get name
"hejin"
127.0.0.1:6379> EXPIRE name 10	# 设置key的过期时间。单位是秒。
(integer) 1
127.0.0.1:6379> ttl name		# 查看当前key的剩余时间
(integer) 2
127.0.0.1:6379> ttl name
(integer) 1
127.0.0.1:6379> ttl name
(integer) -2
127.0.0.1:6379> ttl name
(integer) -2
127.0.0.1:6379> get name
(nil)
127.0.0.1:6379> set name hejin
OK
127.0.0.1:6379> keys *
1) "age"
2) "name"
127.0.0.1:6379> TYPE name		# 查看当前key的类型
string
127.0.0.1:6379> type age
string
127.0.0.1:6379> 

官网查看命令帮助文档:http://www.redis.cn/commands.htmlopen in new window