Redis data types and basic operations You know what? (three)

Redis want to learn how to operate, please first configure Redis environment, the configuration of the small partner does not recommend you take a look on one oh take you quickly install and deploy Redis (b)

Redis data types

Here Insert Picture Description

redis当中一共支持五种数据类型,分别是string字符串类型,list列表类型,集合set类型,hash表类型以及有序集合zset类型,通过这五种不同的数据类型,我们可以实现各种不同的功能,也可以应用与各种不同的场景,接下来我们来看看五种数据类型的操作语法

Here Insert Picture Description

redis当中各种数据类型结构如上图:

redis当中各种数据类型的操作
https://www.runoob.com/redis/redis-keys.html
1, redis string the string operations which
下表列出了常用的 redis 字符串命令

Here Insert Picture Description
Here Insert Picture Description

在这里简单的给大家操作一下:

Here Insert Picture Description
Here Insert Picture Description

2, redis which the operation of the hash list
Redis hash 是一个string类型的field和value的映射表,hash特别适合用于存储对象。
Redis 中每个 hash 可以存储 232 - 1 键值对(40多亿)

下表列出了 redis hash 基本的相关命令:

Here Insert Picture Description

在这里简单的给大家操作一下:

Here Insert Picture Description

3, redis operating on a list which lists
Redis列表是简单的字符串列表,按照插入顺序排序。你可以添加一个元素到列表的头部(左边)或者尾部(右边)
一个列表最多可以包含 232 - 1 个元素 (4294967295, 每个列表超过40亿个元素)。

下表列出了列表相关的基本命令

Here Insert Picture Description

Here Insert Picture Description

在这里简单的给大家操作一下:
还有一道题以及答案给大家分享一下
没有给大家全都操作  list 很重要 大家一定要认真的去多多练习几遍

Here Insert Picture Description
Here Insert Picture Description

4, redis set operation set
redis 的 Set 是 String 类型的无序集合。集合成员是唯一的,这就意味着集合中不能出现重复的数据。
Redis 中集合是通过哈希表实现的,所以添加,删除,查找的复杂度都是 O(1)。
集合中最大的成员数为 232 - 1 (4294967295, 每个集合可存储40多亿个成员)。

下表列出了 Redis 集合基本命令:

Here Insert Picture Description

这有一道Set的题给大家分享一下

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture DescriptionHere Insert Picture Description
Here Insert Picture Description

5, redis operation of the key
下表给出了与 Redis 键相关的基本命令:

Here Insert Picture Description

给大家简单操作一下:

Here Insert Picture Description

6, redis among database
Just know this will do little friends do not seriously Ha this operation is very dangerous! ! ! ! !
	Redis 默认有16个数据库	
	清空某一数据库内的所有数据 
	flushdb
	清空所有数据库的数据 
	flushall
Well, this to write this!
Above, there are many operations, there is no niche operation, little friends can try to manipulate Oh!
Next article for everyone to update API operations Redis Oh! ! ! !
Published 38 original articles · won praise 19 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_44466534/article/details/104886013