Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6763835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:31:25+00:00 2026-05-26T14:31:25+00:00

I would like to store some information as follows (note, I’m not wedded to

  • 0

I would like to store some information as follows (note, I’m not wedded to this data structure at all, but this shows you the underlying information I want to store):

{ user_id: 12345, page_id: 2, country: 'DE' }

In these records, user_id is a unique field, but the page_id is not.

I would like to translate this into a Redis data structure, and I would like to be able to run efficient searches as follows:

  • For user_id 12345, find the related country.
  • For page_id 2, find all related user_ids and their countries.

Is it actually possible to do this in Redis? If so, what data structures should I use, and how should I avoid the possibility of duplicating records when I insert them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:31:26+00:00Added an answer on May 26, 2026 at 2:31 pm

    It sounds like you need two key types: a HASH key to store your user’s data, and a LIST for each page that contains a list of related users. Below is an example of how this could work.

    Load Data:

    > RPUSH page:2:users 12345
    > HMSET user:12345 country DE key2 value2
    

    Pull Data:

    # All users for page 2
    > LRANGE page:2:users 0 -1
    
    # All users for page 2 and their countries
    > SORT page:2:users By nosort GET # GET user:*->country GET user:*->key2
    

    Remove User From Page:

    > LREM page:2:users 0 12345
    

    Repeat GETs in the SORT to retrieve additional values for the user.

    I hope this helps, let me know if there’s anything you’d like clarified or if you need further assistance. I also recommend reading the commands list and documentation available at the redis web site, especially concerning the SORT operation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to track some information on users, but would like to retain it
I would like to store some information in xml format and query it whenever
I would like to store some analytics figures. For example, the amount of times
We would like to some processing in a Java application, store the results in
For some small programs in Python, I would like to set, store and retrieve
I would like to create a file which stores some data that can be
I have this string stored in a variable: IN=bla@some.com;john@home.com Now I would like to
I would like to force a user to complete some additional information once they
I would like to store information in a java collection that is cached in
This question is more of an architecture based question. I would like some solutions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.