开发者

Data modeling practices in Redis? [closed]

Closed. This question does not mee开发者_JAVA技巧t Stack Overflow guidelines. It is not currently accepting answers.

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 9 years ago.

Improve this question

I've recently been getting into Redis and find it very appealing. I'd like to see how far I can push it's limits as a database. I read the Retwis tutorial and found it very interesting. I'm wondering if there are even more resources that give examples of data modeling in Redis? Perhaps something along the lines of a cookbook?

Thanks!

EDIT

So here are some links I've found so far. I'd really like to know some more:

  • Simple social network (starting on slide 23)
  • Autocomplete with Redis
  • Redis from the Ground up (see section "Designing with Redis")
  • There are a few basic examples at the Redis Cookbook


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.


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

  • http://www.paperplanes.de/2010/2/16/a_collection_of_redis_use_cases.html - a bit old but very accurate, 11 examples of Redis commands and how they are used correctly in data modelling
  • http://www.slideshare.net/dvirsky/introduction-to-redis - a presentation by Dvir Volk, a well-known figure in the Redis community, he explains what you can do with Redis including advanced things like pub/sub and transactions, with a use case example of a simple social feed


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜