Proper use of Voldemort as a key-value pair?

I'm trying to figure out how to use Voldermort? Say I have a script like this:

Since Voldemort is a key-value pair. I need to get a value (like some text) based on three parameters.

So what will be the key in this case? I cannot use 3 keys for 1 value to the right, but this value should be searchable based on these three parameters.

Does it make sense?

thanks

EDIT1

for example: a blog system. The user publishes a blog: user data is stored: name, age and gender The content of the blog (text) is saved.

Now, I need to use Voldemort here if the user is looking from the front-end for all Sex: Male blog posts

Then my code should request voldemort and return all the "blog content (text)" in which there is sex as a man.

So, according to my understanding:

Key = Name, Age and Sex Value = Text 

I am using Java.

+4
source share
2 answers

Edited answer to add an example added to the question:

What you need to know about Voldemort is a very simple key store. As far as I know about this, the only thing you can do is save the value under the key and then extract these values โ€‹โ€‹using the key. So, for your example, if you really want to use Voldemort, you have several options.

So, for example, you said that you store data for users. So you might have something like this:

 Key = user-Chad Value = Name:Chad Birch, Age:26, Sex:Male 

Now, if I want to post a new blog post, you also need to save this under the key. So you can do something like this:

 Key = blog-Chad1 Value = Here is my very first blog post. 

Now your problem is that you need to somehow view all the blog posts made by users with Sex: Male, but there is no way to directly get this data. At this point you need to either:

  • Pull out each user, check to see if they are men, and if they are, pull out your blog posts.
  • Start storing more things in other key-value pairs so you can watch it.

To implement # 2, you could add a couple more such as:

 Key = search-Sex:Male Value = Chad1 Chad2 Steve1 ... 

Then, when someone searches for Sex: Male, you pull out the value for it, separate it, and then post all the blog posts.

It makes sense? Using kv store is a little different from the database because you are losing all of these relational features.

+5
source

I donโ€™t think you can do it directly using the keystore, but one way around it is to keep the user in several places.

For example, you have a mapping of user keywords to a list of blog posts. You also have an age mapping against a list of users. Also a gender list of users. Now, if you want to search by age or gender, you select the appropriate list of users, and then retrieve all your blog posts.

Part of the reason key storage can be stored, such as Voldemort, is because storage and queries are cheap enough for you to do extra.

The problem, however, with the above diagram is that if you use Voldemort in a distributed way, you will be better off with a lot of keys that map to short lists of data (so you can distribute based on the key) that- something like matching sex with the user would violate (only a few keys with potentially very large lists of data for each).

+1
source

Source: https://habr.com/ru/post/1305794/


All Articles