翻译文章,原文地址: https://redis.com/blog/diving-into-redis-6/
You know the warning on the shallow end of the pool where it says “NO DIVING”? Well, the new Redis 6 is no shallow update to the world’s most-loved database—it’s so deep you can dive right in. Now that Salvatore Sanfilippo has made Redis 6 generally available, let’s take a dip in the new changes and features.
The new stuff can be divided into a few different categories: security, performance, ease-of-use, and even some entirely new functionality. Each category holds a number of improvements, so read carefully to learn how they can fundamentally change how you use Redis.
Redis 6 brings news security features
Perhaps the biggest, most game-changing feature of Redis 6 are access control lists (ACLs).
最具有变革性的特性是访问控制列表。
ACLs bring the concept of “users” to Redis. Each user can have a defined set of capabilities that dictate which commands they can run and on what keys.
访问控制列表为Redis带来了“用户”的概念。每个用户都可以定义一组特定的能力,以控制他们能运行哪些命令和哪些键。
If you’ve been using Redis for a while, you’ve probably put this feature on your wish list—it reduces the need for oopsy moves like running FLUSHDB on production servers, and lets you do more sophisticated tasks like creating specific users for specific actions so that every action operates with the least required privilege.
Redis clients in Java, Node.js, Python and .NET already support ACLs, and we expect support to rapidly expand to more languages and libraries now that Redis 6 is generally available.
ACLs will allow users access to only particular commands, keys, or even patterns of keys based on user-based specified permissions.
ACLS将允许基于用户权限使用户只能访问特定命令、键、或者特定格式的键。
In addition to ACLs, Redis 6 brings the ability to encrypt traffic over SSL. Up until this version, encryption in Redis was deferred outside the process, meaning it required other applications to provide encryption and that many instances were left unencrypted. This is an important step forward for Redis, allowing for use in more environments where encryption is a critical requirement.
Redis 6提供加密传输的能力。
Redis 6 is faster
Despite Redis’ well-deserved reputation for high performance, its single-threaded architecture has been controversial among engineers who wondered if Redis could be even faster. Redis 6 rings in a new era: while it retains a core single-threaded data-access interface, I/O is now threaded.
Redis6 保留了单线程的数据访问接口,而I/O现在是线程化的。
By delegating the time spent reading and writing to I/O sockets over to other threads, the Redis process can devote more cycles to manipulating, storing, and retrieving data—boosting overall performance.
通过将读写I/O套接字的工作量委托给其他线程,Redis进程可以分配更多的周期来处理、存储和检索数据,提高总体性能。
This improvement retains the transactional characteristics of previous versions, so you don’t have to rethink your applications to take advantage of the increased performance. Similarly, Redis’ single-threaded DEL command can now be configured to behave like the multi-thread UNLINK command that has been available since Redis version 4.
这个提升保留了之前的Redis版本事务性,因此您不需要重新思考您的应用程序来取得更高的性能。
The performance of a local variable is almost always unbeatable, Finally, even a database as high performance as Redis will be much slower than accessing something from the stack or heap. Redis 6 adds a new technique for sophisticated client libraries to implement a client-side caching layer to store a subset of data in your own process. This implementation is smart enough to manage multiple updates to the same data and keep your data as in-sync as possible—while retaining the advantages of Redis with the speed of local variables.
REDIS 6为复杂的客户库库添加了一种新技术,以实现客户端缓存层,以将数据子集存储在您自己的进程中。这个实现很只能,足以管理相同数据的多次更新,并保持数据与本地变量的同步性,同时以本地变量的方式保持了Redis的优势。
Redis 6 is easier to use
For years, the second version of the Redis protocol (RESP2) has proven to be remarkably flexible. It supports not only Redis’ built-in data structures but also Redis modules and the new commands and data that those bring along. Redis 6 starts support for a new version of the protocol, RESP3. This new protocol is an evolution of the previous version that adds richness to results, which let interfacing libraries better map Redis responses with variable types in the host language. Additionally, this version of the protocol paves the way for thinner client libraries with less code and will eventually allow for more-rapid adoption of new commands and modules. RESP2 will be with us for quite a while as it will take the community some time to migrate software, tools, and client libraries to the new protocol. But if you want to dive in headfirst, you can try out RESP3 on Redis 6 now—just understand that RESP3 is still in an early phase of development.
Redis6提供了一个新的协议版本,RESP3。该版本协议较上个版本增加了更丰富的结果内容,这使得接口库可以更好地与Redis响应的变量类型在主机语言中映射。此外,这个版本的协议支撑更细的客户端库,其中代码更少,并最终允许更快的适应新的命令和模块。RESP2将在很长的时间内保留,但如果您想要深入了解,您可以尝试RESP3在Redis6现在,只需理解RESP3还在开发阶段。
Redis Cluster greatly expands the variety of Redis uses, but it does require a more complex client library. In smaller language communities, the client libraries to support cluster never fully emerged. Thankfully, Redis 6.0 comes complete with a cluster proxy to assist language platforms that do not support the Redis Cluster API to connect to Redis clusters. This masks the complexity, so only a simple single-instance library implementation is required.
Redis6.0有一个集群代理来帮助那些不支持Redis集群API的语言平台连接到Redis集群。这使得隐藏了复杂性,所以只需要一个简单的单实例库实现就可以了。
Since Redis 1.0, developers have been able to set keys to expire after a given time, a feature indispensable for caching. This expiration has always relied on sampling techniques to avoid unpredictable delays when many keys expire at the same time. The expiration cycle has been rewritten in Redis 6.0 to allow for much faster expirations that more closely match the time-to-live (TTL) property. Additionally, you can now tune expirations to zero in on the accuracy required for your particular situation.
Redis 1.0伊始,开发者可以设置键的过期时间。这个过期依赖于采样技术,以避免多个键在同一时间过期时随机延迟。Redis 6.0重写了过期周期,以允许更快的过期,这与TTL属性更接近。您还可以调整过期为零,以提供您特定情况的精确度。
Meet the longest common subsequence family
And now for something completely different. In a recent surprise for the community, Salvatore, the author of Redis, released a new command family for version 6. The longest common subsequence (LCS) commands can be used to find non-contiguous sequences among strings.
新增了 LCS 命令组,可以用来在字符串之间找到不连续的序列。
If you’ve ever used a diff, then you’ve indirectly used this algorithm. In Salvatore’s own eponymic example:
STRALGO LCS STRINGS salvatore sanfilippo"salo"
How did this command come up with that result?
**sal~~vat~~o**re **sa**nfi**l**ipp**o**
As you can see, the STRALGO LCS STRINGS command is skipping over a number of bytes—and that can be a different number for each argument trying to find the longest sequence of common bytes.
STRALGO LCS STRINGS 命令是跳过一些字节,并且这个可以不同的数字在每个参数中尝试找到最长的共有字节序列。
That’s only the beginning, there is a lot more to this new capability of Redis. Since the LCS family of commands works on binary data—like almost everything else in Redis—just think about the possibilities outside of text processing. Salvatore has mentioned the possibilities of using it for RNA and DNA analysis. Pretty neat, but keep in mind this is a very new command that you may want to treat like a sandbox—the command name changed as of last week, so don’t be surprised if it isn’t supported everywhere.
这个命令还没有完成,不全都支持。
Get started with Redis 6
Redis 6 opens up vast new possibilities for the Redis community. It brings everything from better security to incremental performance improvements, not to mention being easier to use and introducing new ways to use Redis. If you’re ready to get started, you can download the brand new version right now from redis.io! To learn more about general availability of Redis Enterprise 6.0, which utilizes Redis 6’s improvements and takes Redis security to an even higher level, see our post on Rediscover Redis Security with Redis Enterprise 6.0.