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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:04:21+00:00 2026-06-05T12:04:21+00:00

Using ServiceStack, is there a way to perform multiple read commands (in particular the

  • 0

Using ServiceStack, is there a way to perform multiple read commands (in particular the ContainsKey command)?

The objects stored take a while to fetch from the database, so we’re looking to get only the ones that are not in cache.

I know that I can ask redis for the object and then fetch from the database if it comes back null, but the objects being stored are fairly large, so I’d rather just get a list of bools back and then determine which ids to query in the database from that.

For the time being I’m looping through my list of Ids (can be up to 100 or so) and using the ContainsKey method in servicestack. I’m looking to avoid all of the back and forth and make all of the requests in one shot.

  • 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-05T12:04:24+00:00Added an answer on June 5, 2026 at 12:04 pm

    On the ServiceStack.Redis client you can use GetValues or GetValuesMap (both string and T apis are available) for fetching multiple values (uses MGET) in a single call. Only existing items are returned, which you can detect with GetValues if you have Id‘s on your models or GetValuesMap which returns a dictionary of existing keys and their values.

    From this, you can determine and fetch all the missing Ids from the database. If you’re just going to fetch the existing values from Redis anyway, then this is the most optimal strategy since you can fetch all the values and determine the existing keys with 1 call.

    Alternative ‘Single Call’ options

    Use Pipelining or Transactions

    If for some reason you really only want to check the existence of keys in Redis without fetching them, then you can use a Transaction / or Pipeline (both are pipelined) to queue up multiple operations that gets sent to Redis in 1 socket write. Here’s an example of this from RedisStackOverflow demo that queues up 30 operations that gets send and executed in a single batch.

    Use LUA Scripting

    If you have Redis >v2.5x you can create and execute composite operations using Redis’s server-side LUA support. You can use these APIs from IRedisClient in ServiceStack.Redis client to execute server-side LUA scripts:

    string GetEvalStr(string body, int numOfArgs, params string[] args);
    int GetEvalInt(string body, int numOfArgs, params string[] args);
    List<string> GetEvalMultiData(string body, int numOfArgs, params string[] args);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

AuthorizeAttribute is useless while using ServiceStack.Mvc AuthenticateAttribute is for DTO objects. There is no
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I'm trying to implement a service with Multiple Optional Parameters using ServiceStack.Net At the
Using Flex 3, I would like to take an image snapshot such as this:
I'm looking for at using ServiceStack for the services part of a web application
Using linq2sql I'm trying to take the string in txtOilChange and update the oilChange
Using android 2.3.3, I have a background Service which has a socket connection. There's
I'm trying to create a simple event store using C# and [ServiceStack] Redis. public
have created REST service using servicestack and in post request I have return object
I am using ServiceStack to create a service which accepts request from and HTML

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.