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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:35:11+00:00 2026-06-12T14:35:11+00:00

Can anyone suggest any design pattern to dynamically differentiate the memcahce instances in java

  • 0

Can anyone suggest any design pattern to dynamically differentiate the memcahce instances in java code?

Previously in my application there is only one memcache instance configured this way

Step-1:

dev.memcached.location=33.10.77.88:11211

dev.memcached.poolsize=5

Step-2:

Then i am accessing that memcache in code as follows,

private MemcachedInterface() throws IOException {

    String location =stringParam("memcached.location", "33.10.77.88:11211");

    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses(location));

}

Then i am invoking that memcache as follows in code using above MemcachedInterface(),

Step-3:

MemcachedInterface.getSoleInstance();

And then i am using that MemcachedInterface() to get/set data as follows,

MemcachedInterface.set(MEMCACHED_CUSTS, “{}”);
resp = MemcachedInterface.gets(MEMCACHED_CUSTS);

My question is if i introduce an new memcache instance in our architechture,configuration is done as follows,

Step-1:

dev.memcached.location=33.10.77.89:11211
dev.memcached.poolsize=5

So, first memcache instance is in 33.10.77.88:11211 and second memcache instance is in 33.10.77.89:11211

until this its ok…but….

how to handle Step-2 and Step-3 in this case,To get the MemcachedInterface dynamically.

1)should i use one more interface called MemcachedInterface2() in step-2

Now the actual problem comes in,

I am having 4 webservers in my application.Previoulsy all are writing to MemcachedInterface(),but now as i will introduce one more memcache instance ex:MemcachedInterface2() ws1 and ws2 should write in MemcachedInterface() and ws3 and ws4 should write in ex:MemcachedInterface2()

So,if i use one more interface called MemcachedInterface2() as mentioned above,

This an code burden as i should change all the classes using WS3 and WS4 to Ex:MemcachedInterface2() .

Can anyone suggest one approach with limited code changes??

  • 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-12T14:35:12+00:00Added an answer on June 12, 2026 at 2:35 pm

    xmemcached supports constistent hashing which will allow your client to choose the right memcached server instance from the pool. You can refer to this answer for a bit more detail Do client need to worry about multiple memcache servers?

    So, if I understood correctly, you’ll have to

    1. use only one memcached client in all your webapps
    2. since you have your own wrapper class around the memcached client MemcachedInterface, you’ll have to add some method to this interface, that enables to add/remove server to an existing client. See the user guide (scroll down a little): https://code.google.com/p/xmemcached/wiki/User_Guide#JMX_Support
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Design pattern. Can any one suggest right design pattern for
Can anyone suggest any java library to use Skype public API? I have not
Can anyone suggest any good questions to ask candidates relating to C#, SQL, MVC,
Can anyone suggest a way to shave any time off this script? var countObject
Can anyone suggest any real life example of Hybrid inheritance?
Can anyone suggest any good cURL based PHP browser / spider / crawler /
Can anyone suggest any good algorithms, or their own approach, to calculating the vertices
Can anyone suggest any open source linux program for converting .wav files to flash
Can anyone suggest any pointers / tutorials or information on how to get an
Can anyone suggest any good payment processing libraries for python/django?

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.