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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:50:38+00:00 2026-05-24T20:50:38+00:00

I am currently writing an application that requires bulk operations on a key/value store,

  • 0

I am currently writing an application that requires bulk operations on a key/value store, at this time I am using membase.

spymemcached allows bulk get, but not bulk CAS or add; features that I think would be widely used if implemented.

At this point my code for a set of bulk operations is roughly as shown below.

“client” is a single MemcachedClient.

ArrayList<Future<Boolean>> futures = new ArrayList<Future<Boolean>>();
ArrayList<String> bulkGet = new ArrayList<String>();
for(int i=0; i<50; i++){
    String key = "Key_" + x + "_" + i;
    Future<Boolean> fut = client.add(key, 0, "Value_" + x + "_" + i);
    futures.add(fut);
    bulkGet.add(key);
}

int count = 0;
for(Future<Boolean> fut : futures){
    if(fut.get()==true){
        count++;
    }
}
System.out.println("Added " + count + " records.");

Map<String,Object> bulkGot = client.getBulk(bulkGet);
System.out.println("Retrieved " + bulkGot.size() + " records");

The blocking call on Future.get() seems highly inefficient, is there a better way? In my actual scenario I’d like the ability to handle the futures as soon as they return (which may or may not be in the order in which they were sent?).

Also, are the following operations possible (or planning to be implemented)?

-Add or return existing value

-Delete if value equals a known value

-Set if value equals a known value

Thanks,
Marcus

  • 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-24T20:50:39+00:00Added an answer on May 24, 2026 at 8:50 pm

    I’ll try to address as many things here as possible.

    Spymemcached allows bulk get, but not bulk CAS or add; features that I think would be widely used if implemented.

    I completely agree here, but we probably wouldn’t go about this by adding bulkAdd, bulkCas, … functions to MemcachedClient. Spymemcached currently, by default optimizes get and set operations by sending them as bulk sets or bulk gets whenever it can. There are plans to extend this to all memcached operations, but it hasn’t been done yet. When it is though it will happen behind the scenes and probably won’t be directly available to spymemcached users.

    The blocking call on Future.get() seems highly inefficient?

    Yes, which I will address below, but also note that if this was a bulk operation then your code would still block for a little bit. With individual add operations you code would probably only block for the first operation because after that all of the other operations will have already finished so calls to Future.get() after the first call would return immediately.

    So is there a better way?

    You can extend the MemcachedClient class and copy one of the existing functions and add your own code to the callback function.

    Also, are the following operations possible (or planning to be implemented)?

    Spymemcached implements all of the functionality that memcached offers. The operations you mention can already be build with the the functionality Spymemcached has.

    -Add or return existing value

    add keyA. If it fails get keyA.

    -Delete if value equals a known value

    get keyA. If keyA equals a known value, delete keyA

    -Set if value equals a known value

    get keyA. If keyA equals a known value, set keyB.

    If you are looking to get new options added to memcached then you should post your requests on memcached.org. To be honest though, the memcached guys like to keep the api as small as possible so I don’t think it is likely these will get addded.

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

Sidebar

Related Questions

I am writing an encryption application that requires a 64 bit key. I am
At the office we are currently writing an application that will generate XML files
I'm currently writing an iPhone application that uses a UITabBarController with more than 5
I'm currently writing a C# application that does a lot of digital signal processing,
I'm currently writing a web application that have about 6-12 pages. On each one
I'm writing an application that is currently a pure QT4 app. It is designed
I'm currently writing a small python app that embeds cherrypy and django using py2app.
I'm currently in the process of writing an application that has quite a number
I have an Android application that is very image intensive. I'm currently using Bitmap.createScaledBitmap()
I am currently writing an application that will serve a similar purpose for multiple

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.