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 3677176
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:11:22+00:00 2026-05-19T03:11:22+00:00

Using redis , there are a number of commands to retrieve entire data structures

  • 0

Using redis, there are a number of commands to retrieve entire data structures (LRANGE for lists, SMEMBERS for sets, ZRANGE for sorted sets, and HGETALL for hashes).

Only the hash has a method (HMSET) to insert multiple items with a single command.

All of the examples I’ve seen have shown just adding a single item at a time to a list (through RPUSH or LPUSH) or a set (through SADD/ZADD).

The more specific problem that I want to solve is to create lists and sorted sets containing database ids, these lists are unique to each user and contain a few hundred to a few thousand ids.

They are normally gathered from a database query, massaged a little bit in memory and then stored in redis for either paginating through (lists) or doing set based operations on to retrieve subsets (sets and sorted sets).

Currently, I’m iterating through the list and calling the appropriate add method for each element. This has the drawbacks of making multiple requests over the wire and repeating the key every time.

redis> RPUSH employee:ids 1000
(integer) 1
redis> RPUSH employee:ids 1001
(integer) 2
redis> RPUSH employee:ids 1002
(integer) 3
redis> RPUSH employee:ids 1003
(integer) 4
redis> del employee:ids
(integer) 1

I’m thinking that using a transaction with MULTI and EXEC could help to turn it into a single request, but that wouldn’t help with the repeated key.

redis> MULTI
OK
redis> RPUSH employee:ids 1000
QUEUED
redis> RPUSH employee:ids 1001
QUEUED
redis> RPUSH employee:ids 1002
QUEUED
redis> RPUSH employee:ids 1003
QUEUED
redis> RPUSH employee:ids 1004
QUEUED
redis> EXEC
1. (integer) 1
2. (integer) 2
3. (integer) 3
4. (integer) 4
5. (integer) 5

Is there something that I’m missing that would let me add elements to lists/sets in a single command, or without repeating the key every time?

I’m also using the jedis client library if that matters (or if there’s another library that I can use from the JVM that’d be better).

  • 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-19T03:11:23+00:00Added an answer on May 19, 2026 at 3:11 am

    Setting up a transaction won’t help here. The purpose of transactions is to ensure the commands get executed at the same time so you never have half a list on the server. They still get sent one at a time.

    Are the multiple commands really causing performance issues? 1000 items isn’t actually that many, and as long as you aren’t doing something like opening a new connection for each item there shouldn’t be any latency issues.

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

Sidebar

Related Questions

Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using ASP.NET MVC there are situations (such as form submission) that may require a
in Redis ( http://code.google.com/p/redis ) there are scores associated to elements, in order to
I'm using Rails with redis. From the introduction of Redis, I found such information:
I'm using an ORM called Ohm in Ruby that works on top of Redis
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button

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.