Redis Manifesto 中译(Redis 宣言)

本文发表于2011年3月1日

我经常不知道如何准确回应很多功能需求的添加请求,以及 Redis 中为什么要以某种特定方式来实现某种功能的疑问。大多数情况下这些疑问都很有意义,在编程领域总是有不止一种方法来完成一件事,这更多关乎于你对如何编码开发软件的品位、感觉以及想法。因此我尝试在这篇宣言中简要的说明我对于 Redis 甚至软件开发的一些想法,这个宣言以后也将会被包含在Redis 软件的分发包中。这世上有无数种方法去做事情,只有那么一种是我以及 Redis 社区中好的一面所拥有的。

Redis 宣言

1、 A DSL for Abstract Data Types. Redis is a DSL (Domain Specific Language) that manipulates abstract data types and implemented as a TCP daemon. Commands manipulate a key space where keys are binary-safe strings and values are different kinds of abstract data types. Every data type represents an abstract version of a fundamental data structure. For instance Redis Lists are an abstract representation of linked lists. In Redis, the essence of a data type isn't just the kind of operations that the data types support, but also the space and time complexity of the data type and the operations performed upon it.

一种抽象数据类型的 DSL。Redis 提供基于 TCP 协议实现的操作多种抽象数据类型的 DSL。Redis 提供各种命令用于操作基于二进制安全字符串作为 key,各种抽象数据类型数据为 value 结构的数据。每种抽象数据类型代表了一种基础的数据结构,例如 Redis 中的 Lists 代表了基于链表的列表结构。在 Redis 中数据类型的本质不仅仅包含了这种数据结构提供的操作方式,还包括这种数据结构以及所提供的操作的时间空间复杂度。(译者的理解:定义了所谓的data structures server数据结构服务器)

2、Memory storage is #1. The Redis data set, composed of defined key-value pairs, is primarily stored in the computer's memory. The amount of memory in all kinds of computers, including entry-level servers, is increasing significantly each year. Memory is fast, and allows Redis to have very predictable performance. Datasets composed of 10k or 40 millions keys will perform similarly. Complex data types like Redis Sorted Sets are easy to implement and manipulate in memory with good performance, making Redis very simple. Redis will continue to explore alternative options (where data can be optionally stored on disk, say) but the main goal of the project remains the development of an in-memory database.

内存存储是根本。Redis 中各种基于 key-value 对的数据必然是优先存储于内存的。如今在各种计算机包括入门级的服务器中内存的数量都在逐年大幅增长。内存极快的读写速度保证了 Redis 可观的性能表现。数据量即是从10k变化到40M k依旧能够保持相似的性能表现。类似 Redis 中的Sorted Sets 的复杂数据类型因此也很容易实现并具有很好的性能表现,这使得Redis是简洁的。 Redis 也会继续探索别的可选选择(例如硬盘存储),但这个项目的主要目标始终是开发一个基于内存的数据库。(译者的理解:相对于Kafka是一块抽象的硬盘,而Redis就是一块抽象的内存)

3、Fundamental data structures for a fundamental API. The Redis API is a direct consequence of fundamental data structures. APIs can often be arbitrary but not an API that resembles the nature of fundamental data structures. If we ever meet intelligent life forms from another part of the universe, they'll likely know, understand and recognize the same basic data structures we have in our computer science books. Redis will avoid intermediate layers in API, so that the complexity is obvious and more complex operations can be performed as the sum of the basic operations.

为基础数据结构提供基础的API。Redis 提供的 API 都是直接来源于基础的数据结构的操作逻辑。API 经常会被设计得很随意,但是这些 API 往往都不能像每种数据结构提供的最基础的操作那样自然而然。假如有一种我们从未遇到的来自宇宙的智慧生物,他们也能理解计算机科学书中的这些如此基础数据结构。因此 Redis 将会避免提供中间层的 API,复杂逻辑的复杂度应当直观暴露出来,并且也可以通过这些基础的操作组合实现更复杂的操作。(译者的理解:作为基础中间件的定位和觉悟,更多带有复杂逻辑的API可以由像Redisson这样的项目去实现)

4、Code is like a poem; it's not just something we write to reach some practical result. Sometimes people that are far from the Redis philosophy suggest using other code written by other authors (frequently in other languages) in order to implement something Redis currently lacks. But to us this is like if Shakespeare decided to end Enrico IV using the Paradiso from the Divina Commedia. Is using any external code a bad idea? Not at all. Like in "One Thousand and One Nights" smaller self contained stories are embedded in a bigger story, we'll be happy to use beautiful self contained libraries when needed. At the same time, when writing the Redis story we're trying to write smaller stories that will fit in to other code.

代码就像是诗歌;他们并非只是为了实现某个实际目的地而被写出来。 经常会有不那么理解 Redis 这些哲学的人来建议我们采用一些其他作者写的(常常还是其他语言的)代码来实现一些 Redis 当前还没有的功能。这对于我们来说就好像是莎士比亚决定用但丁《神曲》中的天堂篇作为《亨利四世》的结尾。不过这也不是说完全不采纳外部的代码,就像《一千零一夜》那样,其中每个人的小故事将会组成一个大故事,我们很乐意在需要时使用那些优美简洁的的代码库。在我们编写“Redis”这个大故事的同时也是在写很多个能够相互契合更小的故事。(译者的理解:作者还有点小傲娇小情怀)

5、We're against complexity. We believe designing systems is a fight against complexity. We'll accept to fight the complexity when it's worthwhile but we'll try hard to recognize when a small feature is not worth 1000s of lines of code. Most of the time the best way to fight complexity is by not creating it at all.

我们反对复杂。我们相信设计系统就是一场对抗复杂性的战斗。我们会为值得之处而与复杂斗争,也会努力辨认出为了一个小功能而增加上千行代码的无意义行为。大多数时候最好的战胜复杂性的方法就是不产生这样复杂的问题。(译者的理解:关于复杂功能与实现的一种取舍,尽量减少复杂性,复杂性充满了挑战,每一个复杂需求都要谨慎对待之)

6、 Two levels of API. The Redis API has two levels: 1) a subset of the API fits naturally into a distributed version of Redis and 2) a more complex API that supports multi-key operations. Both are useful if used judiciously but there's no way to make the more complex multi-keys API distributed in an opaque way without violating our other principles. We don't want to provide the illusion of something that will work magically when actually it can't in all cases. Instead we'll provide commands to quickly migrate keys from one instance to another to perform multi-key operations and expose the tradeoffs to the user.

两个层面的 API,Redis的API分为两种,1) 一部分天生适用于分布式的 API 2)另一部分是更复杂的支持multi-key操作的 API ,如果使用得当两种类型的的API都非常有用,但是我们不能在不违反我们的原则的前提下为复杂的支持 multi-keys 操作的API提供逻辑透明的分布式支持。我们不想造成一些功能看似能神奇完成任务实际却并不能适用于所有情况的假象。作为替代,我们会提供快速迁移不同 Redis 实例之间数据的命令用以支持实现分布式中 multi-key 操作,用户可以自己权衡处理(译者的理解:对于分布式Redis确实有点力不从心的,分布式组织逻辑确实很复杂)

7、We optimize for joy. We believe writing code is a lot of hard work, and the only way it can be worth is by enjoying it. When there is no longer joy in writing code, the best thing to do is stop. To prevent this, we'll avoid taking paths that will make Redis less of a joy to develop.

我们优化只是为了开心。我们相信编码本是一件充满艰难的工作,唯一让人觉得值得的方法就是享受其中。如果真的到了不能从编码中感到乐趣的时候就应该停止了。为了防止这样的情况,我们将会避免讨论那些让 Redis 变的无趣的事。(译者的理解:疯狂优化是不可能的,我们做优化是因为觉得做优化有意思)

原文链接:http://oldblog.antirez.com/post/redis-manifesto.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值