Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
您的要求有一个问题:这完全取决于您的数据。
从根本上来说,Redis 是一个数据结构服务器。如何构建数据几乎完全取决于数据是什么以及您需要如何访问它。您列出的链接很好地涵盖了简单和常见的情况。
根据我的经验,Redis 设计更多的是“我的结构有多简单?”。您可以通过哈希对数据进行建模吗?如果是这样,请使用 Redis 中的哈希命令。您需要组合集合和键值或哈希吗?然后在redis中做同样的事情。本质上,假设您没有使用数据库。如果您完全在编程语言和内存中完成此操作,您将如何对数据进行建模?很可能这就是您在 Redis 中所做的事情 - 或者足够接近以弄清楚其余部分。
这并不是说特定的使用模式不会出现。我认为他们已经开始这样做了。例如,一个常见问题是关于 Web 访问日志存储/计算,并且这些工作产生了常见模式。然而,我再次期望它们本质上反映编程语言常见的内存结构,例如散列、集合、有序集合、列表、键值(即变量)和原子计数器。此外,大多数将特定于正在编写的程序。我怀疑这就是为什么这本食谱仍然稀疏的原因(而且现在还为时过早)。
我建议加入 redis 列表并在那里讨论特定需求。
There is a catch in what you ask for: it all depends on your data.
Fundamentally Redis is a data structure server. How you structure your data depends almost entirely on what it is and how you need to access it. The simple and common cases are fairly well covered by the links you list.
Designing for Redis in my experience is more along the lines of "how simple is my structure?". Can you model your data via hash? If so, use the hash commands in Redis. Do you need to combine sets and key-values or hashes? Then do it the same in redis. Essentially, assume you were not using a database. If you did it entirely within your programming language and in memory, how would you model your data? Odds are that is how you'd do it in Redis - or close enough to figure the rest out.
That isn't to say that specific usage patterns will not emerge. I think they are starting to. For example a common question is about web access log storage/calculation and there are common patterns coming out of those efforts. Yet there again I expect them to essentially mirror in-memory structures common to programming languages such as hashes, sets, ordered sets, lists, key-value (ie. the variable), and atomic counters. Further, most will be specific to the program being written. I suspect that is why the cookbook is still sparse (that and it is still early).
I'd suggest joining the redis list and discussing particular needs there.
这里还有两个对 Redis 数据建模有帮助的资源:
Here are a two more resources that could be helpful for Redis data modeling:
我会阅读 Redis 文档 (redis.io)。它们提供了一些非常有用的方法来鼓励人们使用 Redis 以及处理不同类型的数据。即使阅读常见问题解答也会告诉您有用的信息(或者对我有用)。我学习的方法就是尝试使用redis复制mysql软件。它让你跳出框框思考。
I would give the Redis Docs a read (redis.io). They provide some very useful incites into using redis, and working with different kinds of data. Even reading the FAQ will tell you stuff that will come in useful (or it did for me). The way I learned is just to try and replicate mysql software in using redis. It makes you think outside the box.