加入Redis的替代方案

时间:2016-07-08 05:06:06

标签: c# redis

我在Redis中创建了两个名为Person and Account的哈希键值对。 Person键具有该人员的名字和姓氏,而Account Key包含帐户类型和节省。现在我想进行类似于SQL连接(内连接)的连接,以从两个哈希值中检索每个人的帐户类型和节省。

请帮助我找到解决此问题的方法,有人可以帮我设置Redis哈希键值对中的主键和外键。enter image description here

1 个答案:

答案 0 :(得分:0)

Redis不是为了这个目的而服务的。但仍然作为一种解决方法,你可以尝试这样的事情。

在每个Person哈希中都有一个表示帐户ID的值。

hmset person:0 first_name aswathy last_name jacob account_id 1

您的帐户哈希值将如下所示

hmset account:1 type x savings xxx

现在为了实现加入。写一个lua代码,或者像这样的应用程序逻辑。

temp = hgetall person:0 -> temp is a hashmap
temp1 = hgetall "account:"+temp.get(account_id) -> this will get you all the info in that account
put temp and temp1 in a map and return it

结果地图将为您提供相当于连接的结果。

相关问题