English 中文(简体)
如何在重新处置过程中模仿这种废墟结构
原标题:How to model this ruby structure in redis
  • 时间:2009-11-23 18:45:06
  •  标签:
  • ruby
  • redis

I m thinking use redis (http://code.google.com/p/redis/) to store this kind of ruby data structure.

证明:

node1server1 = { "volume1" => 10400, "volume2" => 11221, "volume3" => 13212, "volume4" => 17227 }
node1server2 = { "volume1" => 17450, "volume2" => 14241, "volume3" => 15512, "volume4" => 12427 }

node2server1 = { "volume1" => 17655, "volume2" => 16754, "volume3" => 19877, "volume4" => 10000 }
node2server2 = { "volume1" => 11456, "volume2" => 13776, "volume3" => 18766, "volume4" => 16555 }

何种数据重新分类?

数据需要更新,一是需要区分Node1server1+node1server2和Node2server1+node2server2。

问题回答

我可以看到,这是自你公布以来的一段时期,但你能够提供更多资料,说明如何对数据进行分类?

此外,我假定下文中显示,每个服务器的容量可能各不相同,每个网点的服务器数量也各不相同。

一种方式是:

node_id:1:server_id:1:volume_id:1 = 10400
node_id:1:server_id:1:volume_id:2 = 11221
node_id:1:server_id:1:volume_id:3 = 13212
node_id:1:server_id:1:volume_id:4 = 17227
node_id:1:server_id:2:volume_id:1 = 17450
node_id:1:server_id:2:volume_id:1 = 14241
...
node_id:1:volumes = SET("server_id:1:volume_id:1", "server_id:1:volume_id:2", "server_id:1:volume_id:3", "server_id:1:volume_id:4", "server_id:2:volume_id:1", "server_id:2:volume_id:2", "server_id:2:volume_id:3", "server_id:2:volume_id:4")

因此,为第1号:

SORT node_id:1:volumes BY node_id:1:*

......将按每一节点所分配的数值和分类的 no:1:volumes。

或者,你可以使用Redis1.1中新加入的ZSET。

还指出,我在这里使用了SETs,而不是LIST。 我发现,LIST对于从问答和摇篮角度描述的结构更有用,SETs对独特物品清单来说更有利。

<>References:





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签