Redis之五种数据类型的简单增删改查
开心一笑 乌龟受伤。让蜗牛去买药。过了2个小时。蜗牛还没回来。乌龟急了骂道:他妈的再不回来老子就死了!这时门外传来了蜗牛的声音:你他妈再说老子不去了! 提出问题 Redis五种数据类型的简单增删改查命令??? 解决问题 假设你已经安装Redis服务器; 假
开心一笑
乌龟受伤。让蜗牛去买药。过了2个小时。蜗牛还没回来。乌龟急了骂道:他妈的再不回来老子就死了!这时门外传来了蜗牛的声音:你他妈再说老子不去了!
提出问题
Redis五种数据类型的简单增删改查命令???
解决问题
假设你已经安装Redis服务器;
假设你已经打开Redis cli命令行工具;
假设你对Redis有所了解;
Redis简单增删改查例子
例一:字符串的增删改查
<code>#增加一个key为ay_key的值 127.0.0.1:6379> set ay_key "ay" OK #查询ay_key的值 127.0.0.1:6379> get ay_key "ay" #修改ay_key的值 127.0.0.1:6379> set ay_key "new_ay" OK 127.0.0.1:6379> get ay_key "new_ay" #修改ay_key名称 127.0.0.1:6379> rename ay_key new_ay_key OK 127.0.0.1:6379> keys * 1) "new_ay_key" #删除ay_key 127.0.0.1:6379> del ay_key (integer) 0 #查询是否存在ay_key 0 127.0.0.1:6379> exists ay_key (integer) 0 </code>
例二:Set集合的增删改查
<code>#删除当前选择数据库中的所有key 127.0.0.1:6379> flushdb OK #生成set集合,添加4个数据 127.0.0.1:6379> sadd set_ay_key "ay" "al" "xy" "xl" (integer) 4 #查询set里面所有值 127.0.0.1:6379> smembers set_ay_key 1) "xy" 2) "al" 3) "ay" 4) "xl" #删除value为"xl" , 返回 1 如果没有返回 0 127.0.0.1:6379> srem set_ay_key "xl" (integer) 1 127.0.0.1:6379> smembers set_ay_key 1) "xy" 2) "al" 3) "ay" #添加value为"xl" 127.0.0.1:6379> sadd set_ay_key "xl" (integer) 1 127.0.0.1:6379> smembers set_ay_key 1) "xy" 2) "al" 3) "ay" 4) "xl" #添加value为"xl" 添加不进去,但也不报错,set是不允许重复的 127.0.0.1:6379> sadd set_ay_key "xl" (integer) 0 #不多解释 127.0.0.1:6379> sadd set_ay_key "xl" (integer) 0 #不多解释 127.0.0.1:6379> sadd set_ay_key "xl" (integer) 0 </code>
例三:List集合的增删改查
<code>#添加key为list_ay_key的list集合 127.0.0.1:6379> lpush list_ay_key "ay" "al" "xy" "xl" (integer) 4 #查询key为list_ay_key的集合 127.0.0.1:6379> lrange list_ay_key 0 -1 1) "xl" 2) "xy" 3) "al" 4) "ay" #往list尾部添加元素 127.0.0.1:6379> rpush list_ay_key "together" (integer) 5 #往list头部添加元素 127.0.0.1:6379> lpush list_ay_key "first" (integer) 6 #查询list集合 127.0.0.1:6379> lrange list_ay_key 0 -1 1) "first" 2) "xl" 3) "xy" 4) "al" 5) "ay" 6) "together" #更新index为0的值 127.0.0.1:6379> lset list_ay_key 0 "update_first" OK 127.0.0.1:6379> lrange list_ay_key 0 -1 1) "update_first" 2) "xl" 3) "xy" 4) "al" 5) "ay" 6) "together" #删除index为1上的值 127.0.0.1:6379> lrem list_ay_key 1 "update_first" (integer) 1 127.0.0.1:6379> lrange list_ay_key 0 -1 1) "xl" 2) "xy" 3) "al" 4) "ay" 5) "together" </code>
例四:Hash集合(类似Java)的增删改查
<code>127.0.0.1:6379> flushdb OK #生成hash集合,并添加key 为uuid_one value 为"12345" 127.0.0.1:6379> hset hash_ay_key "uuid_one" "12345" (integer) 1 127.0.0.1:6379> hlen hash_ay_key (integer) 1 #返回集合所有的key 127.0.0.1:6379> hkeys hash_ay_key 1) "uuid_one" #返回集合所有value 127.0.0.1:6379> hvals hash_ay_key 1) "12345" #集合添加值 127.0.0.1:6379> hset hash_ay_key "uuid_two" "22222" (integer) 1 #集合添加值 127.0.0.1:6379> hset hash_ay_key "uuid_three" "33333" (integer) 1 #获得key为uuid_one的值 127.0.0.1:6379> hget hash_ay_key uuid_one "12345" #删除key为uuid_three的值 127.0.0.1:6379> hdel hash_ay_key uuid_three (integer) 1 127.0.0.1:6379> hkeys hash_ay_key 1) "uuid_one" 2) "uuid_two" #获得所有,包括key和value 127.0.0.1:6379> hgetall hash_ay_key 1) "uuid_one" 2) "12345" 3) "uuid_two" 4) "22222" #更新key为uuid_one的值 127.0.0.1:6379> hset hash_ay_key uuid_one "11111" (integer) 0 127.0.0.1:6379> hset hash_ay_key "uuid_one" "11111" (integer) 0 127.0.0.1:6379> hgetall hash_ay_key 1) "uuid_one" 2) "11111" 3) "uuid_two" 4) "22222" </code>
例四:SortedSet集合的增删改查
SortedSet是有序的set集合
<code>#sorted set添加值ay 排序值为 1 127.0.0.1:6379> zadd zset_ay_key 1 "ay" (integer) 1 127.0.0.1:6379> zadd zset_ay_key 2 "al" (integer) 1 127.0.0.1:6379> zadd zset_ay_key 3 "xy" (integer) 1 127.0.0.1:6379> zadd zset_ay_key 4 "xl" (integer) 1 #查询所有的值 127.0.0.1:6379> zrange zset_ay_key 0 -1 1) "ay" 2) "al" 3) "xy" 4) "xl" #删除所有的值 127.0.0.1:6379> zrem zet_ay_key "xl" (integer) 0 127.0.0.1:6379> zrange zset_ay_key 0 -1 1) "ay" 2) "al" 3) "xy" 4) "xl" </code>
不写了,好累,都一样,看下面的文章…..
参考高手文章
http://www.runoob.com/redis/redis-sorted-sets.html
读书感悟
来自《长江七号》
- 星爷”对儿子的家训(片中反复出现了3次)——我们虽然穷,但是不能说谎,也不能打人;不是我们的东西,我们不能拿;要好好读书,长大要做个对社会有用的人。
其他
如果有带给你一丝丝小快乐,就让快乐继续传递下去,欢迎转载,点赞,顶,欢迎留下宝贵的意见,多谢支持!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

1. Start the [Start] menu, enter [cmd], right-click [Command Prompt], and select Run as [Administrator]. 2. Enter the following commands in sequence (copy and paste carefully): SCconfigwuauservstart=auto, press Enter SCconfigbitsstart=auto, press Enter SCconfigcryptsvcstart=auto, press Enter SCconfigtrustedinstallerstart=auto, press Enter SCconfigwuauservtype=share, press Enter netstopwuauserv , press enter netstopcryptS

Recently, the military circle has been overwhelmed by the news: US military fighter jets can now complete fully automatic air combat using AI. Yes, just recently, the US military’s AI fighter jet was made public for the first time and the mystery was unveiled. The full name of this fighter is the Variable Stability Simulator Test Aircraft (VISTA). It was personally flown by the Secretary of the US Air Force to simulate a one-on-one air battle. On May 2, U.S. Air Force Secretary Frank Kendall took off in an X-62AVISTA at Edwards Air Force Base. Note that during the one-hour flight, all flight actions were completed autonomously by AI! Kendall said - "For the past few decades, we have been thinking about the unlimited potential of autonomous air-to-air combat, but it has always seemed out of reach." However now,

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

The caching strategy in GolangAPI can improve performance and reduce server load. Commonly used strategies are: LRU, LFU, FIFO and TTL. Optimization techniques include selecting appropriate cache storage, hierarchical caching, invalidation management, and monitoring and tuning. In the practical case, the LRU cache is used to optimize the API for obtaining user information from the database. The data can be quickly retrieved from the cache. Otherwise, the cache can be updated after obtaining it from the database.

70B model, 1000 tokens can be generated in seconds, which translates into nearly 4000 characters! The researchers fine-tuned Llama3 and introduced an acceleration algorithm. Compared with the native version, the speed is 13 times faster! Not only is it fast, its performance on code rewriting tasks even surpasses GPT-4o. This achievement comes from anysphere, the team behind the popular AI programming artifact Cursor, and OpenAI also participated in the investment. You must know that on Groq, a well-known fast inference acceleration framework, the inference speed of 70BLlama3 is only more than 300 tokens per second. With the speed of Cursor, it can be said that it achieves near-instant complete code file editing. Some people call it a good guy, if you put Curs

In PHP development, the caching mechanism improves performance by temporarily storing frequently accessed data in memory or disk, thereby reducing the number of database accesses. Cache types mainly include memory, file and database cache. Caching can be implemented in PHP using built-in functions or third-party libraries, such as cache_get() and Memcache. Common practical applications include caching database query results to optimize query performance and caching page output to speed up rendering. The caching mechanism effectively improves website response speed, enhances user experience and reduces server load.

Last week, amid the internal wave of resignations and external criticism, OpenAI was plagued by internal and external troubles: - The infringement of the widow sister sparked global heated discussions - Employees signing "overlord clauses" were exposed one after another - Netizens listed Ultraman's "seven deadly sins" Rumors refuting: According to leaked information and documents obtained by Vox, OpenAI’s senior leadership, including Altman, was well aware of these equity recovery provisions and signed off on them. In addition, there is a serious and urgent issue facing OpenAI - AI safety. The recent departures of five security-related employees, including two of its most prominent employees, and the dissolution of the "Super Alignment" team have once again put OpenAI's security issues in the spotlight. Fortune magazine reported that OpenA

First you need to set the system language to Simplified Chinese display and restart. Of course, if you have changed the display language to Simplified Chinese before, you can just skip this step. Next, start operating the registry, regedit.exe, directly navigate to HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNlsLanguage in the left navigation bar or the upper address bar, and then modify the InstallLanguage key value and Default key value to 0804 (if you want to change it to English en-us, you need First set the system display language to en-us, restart the system and then change everything to 0409) You must restart the system at this point.
