Redis MSET 命令
发表于|更新于|Redis教程
|浏览量:
语法
1 | MSET key value [key value ...] |
可用版本
≥ 1.0.1
时间复杂度
$O(N)$
其中 N 是要设置的 key 的数量。
ACL类别
@write, @string, @slow
将给定的键设置为它们各自的值。MSET 用新的值替换现有的值,就像普通的 SET 一样。如果你不想覆盖现有的值,请参阅 MSETNX。
MSET 是原子性的,所以所有给定的键都是一次性设置的。也就是说,客户端不可能看到一些键被更新而另一些键没有变化。
返回值
总是返回 OK,因为 MSET 命令永远不会失败。
示例
1 | redis> MSET key1 "Hello" key2 "World" |
(END)
文章作者: Johnson Lin
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Johnson Lin!
相关推荐
2019-12-19
Spring Boot 2.x 集成Redis示例
一、如何集成首先,在 pom 文件新增 redis 依赖: 1234<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId></dependency> 接着修改项目配置文件 application.properties,增加 redis 配置 1234# redis hostspring.redis.host=172.24.58.226# redis portspring.redis.port=6379 经过上面简单的两步,即可在项目中使用 StringRedisTemplate 和 RedisTemplate<Object,Object>,因为从 Spring Boot 2.0 开始,Spring 容器是自动生成了这两个实例,可以直接注入使用。如以下代码片段: 12345678910111213@Autowiredprivat...
2024-07-25
How to learn Redis effectively?
Redis, an open-source, high-performance in-memory data structure store, is renowned for its speed, versatility, and simplicity. It has gained immense popularity and is widely utilized for caching, distributed locks, session management, real-time analytics, and more. Whether you’re a developer looking to expand your skills or an IT professional aiming to optimize data handling, mastering Redis can significantly enhance your proficiency. Here’s a comprehensive guide on how to learn Redis effect...

2024-09-10
Analyzing Redis Source Code: Simple Dynamic Strings (SDS) – An Efficient and Flexible String Implementation
Redis’s Requirements for StringsStrings are an essential data type in app development, frequently used to store a variety of information such as user profiles, product descriptions, and system messages. In Redis, a popular in-memory data store, both the keys and often the values in key-value pairs are represented as strings. This makes strings one of the foundational data types in Redis, contributing to its flexibility and simplicity when handling data. For instance, when saving user data su...
2024-10-08
Redis Set SINTERCARD Command
The Redis SINTERCARD command returns the cardinality of the set which would result from the intersection of all the given sets. Keys that do not exist are considered to be empty sets. With one of the keys being an empty set, the resulting set is also empty (since set intersection with an empty set always results in an empty set). SyntaxThe basic syntax of the SINTERCARD command is as follows: 1SINTERCARD numkeys key [key ...] [LIMIT limit] This command is similar to SINTER, but instead of ret...
2024-11-06
Redis HyperLogLog PFCOUNT Command
The Redis PFCOUNT command returns the cardinality estimate of the given HyperLogLog. SyntaxThe basic syntax of the PFCOUNT command is as follows: 1PFCOUNT key [key ...] Available SinceRedis version 2.8.9 and later. Time Complexity O(1) when called with a single key. O(N) when called with multiple keys, where N is the number of keys. ACL Categories@read, @hyperloglog, @slow Return ValueAn integer representing the cardinality of the given HyperLogLog. If multiple HyperLogLogs are provided, r...
2023-06-03
Redis LCS 命令
语法1LCS key1 key2 [LEN] [IDX] [MINMATCHLEN min-match-len] [WITHMATCHLEN] 可用版本 ≥ 7.0.0 时间复杂度 $O(N*M)$ 其中 N 和 M 分别是 s1 和 s2 的长度。 ACL类别 @read, @string, @slow LCS 命令实现了最长的公共子序列算法。请注意,这与最长公共字符串算法不同,因为字符串中的匹配字符不需要是连续的。 例如,”foo” 和 “fao” 之间的 LCS 是 “fo”,因为从左到右扫描这两个字符串,最长的共同字符集是由第一个 “f”,然后是 “o”组成。 LCS 对于评估两个字符串的相似程度非常有用。字符串可以表示很多东西。例如,如果两个字符串是 DNA 序列,LCS 将提供两个 DNA 序列之间的相似性度量。如果字符串表示某些用户编辑的某些文本,则 LCS 可以表示新文本与旧文本相比有何不同,等等。 请注意,此算法的运行时间复杂度为 $O(N×M)$,其中 N 是第一个字符串的长度,M 是第二个字符串的长度。因此,要么启动一个不同的 Redis 实例来运行这个命...

