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

  • Home
  • SEARCH
  • 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 8167147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:06:48+00:00 2026-06-06T20:06:48+00:00

Redis is conceptually different from traditional SQL databases that I use, and I’m trying

  • 0

Redis is conceptually different from traditional SQL databases that I use, and I’m trying to figure out if it is right for my project… I’ve been looking around but can’t seem to find an answer to my question.

I have a set of Users that I need to store, each with a unique ID and several values (such as their name) associated with it. It seems like I can simply store those as a hash:

user:fef982dcfe1a7bcba4849b4c281bba95
"username" "andrewm" "name" "Andrew"

I also have a bunch of messages I want to store, each having a few properties such as the sender and recipient:

message:1a7bcba4849b4c281bfef98a952dcfeb
"sender" "fef982dcfe1a7bcba4849b4c281bba95" "recipient" "82dcfe1a7bcba4849b4c281bba95fef9" "message" "Hi!"

My question is, how would I go about retrieving all of the messages that are sent by a specific user (designated by a their hash). Should I be using a traditional relational database instead, or even a NoSQL database like MongoDB (which I’ve used before)? If so, does anyone have any suggestions for high performance stores? I won’t be doing any true searching (i.e. MySQL LIKE queries)– just key value lookups, really.

  • 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-06-06T20:06:50+00:00Added an answer on June 6, 2026 at 8:06 pm

    It is certainly possible to model these data with Redis, but you need to think in term of data structures AND access paths. With Redis the access paths are not managed implicitly (like with indexes in RDBMS/MongoDB).

    For the provided example, you could have:

    user:<user hash> -> hash of user properties
    user:<user hash>:sent -> set of <msg hash>
    user:<user hash>:received -> set of <msg hash>
    message:<msg hash> -> hash of message properties
    

    Adding/deleting a message would mean maintaining the *:sent and *:received sets corresponding to the senders and recipients, on top of adding/deleting the message object itself.

    Retrieving sent or received messages for a given user is just a SMEMBERS command, or a SORT if you want to retrieve also the properties of the message at the same time:

    # Get a list of message hash codes only in one roundtrip
    smembers user:<user hash>:received
    
    # Get a list of message contents in one roundtrip
    sort user:<user hash>:received by nosort get message:*->sender get message:*->message
    

    For the rationale about using sort, see:

    • Getting multiple key values from Redis
    • Need help conceptualizing in Redis/NoSQL

    Note 1: with Redis it is better to use integers as keys rather than UUID or hash codes (especially in sets), since they are stored in a more efficient way.

    Note 2: if you need to order the messages, then lists must be used instead of sets. The consequence is only oldest messages can be removed, and only newset messages can be added in an efficient way. You would probably to also add a global list for all messages.

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

Sidebar

Related Questions

I'm integrating redis into my NodeJS server app, and I'm trying to figure out
I am trying to use redis and redis-store with rails 3.1; however I seem
We use redis to store 'active' information that we need to recall quickly. Do
I want to use Redis as a database, not a cache. From my (limited)
I'm new to redis, and I'm trying out various examples. However, it doesn't seem
I have substitute my memcache with Redis. I use the phpredis client and the
I am pretty new to Redis. I downloaded Jedis and added that to my
I want to use redis for my game's leaderboard data and I have seen
I am using Redis to store two databases : 0 and 1 via the
If using Redis , we can use one record (sets and ordered sets) to

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.