Redis 中的数据建模实践?

发布于 2024-10-16 01:13:08 字数 1536 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不可一世的女人 2024-10-23 01:13:08

您的要求有一个问题:这完全取决于您的数据。

从根本上来说,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.

等你爱我 2024-10-23 01:13:08

这里还有两个对 Redis 数据建模有帮助的资源:

Here are a two more resources that could be helpful for Redis data modeling:

_蜘蛛 2024-10-23 01:13:08

我会阅读 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文