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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:12:30+00:00 2026-06-14T02:12:30+00:00

I have a memcached state in which I want to save something. When a

  • 0

I have a memcached state in which I want to save something. When a node connects to the topology of my application, I would like it to add itself to the list of connected nodes of that kind. I’m trying to do this through nesting queries:

mc_cli.connect(function() {
mc_cli.get( key, function(err, response) {
    if(err.type == 'NOT_FOUND'){
        //save myself
        mc_cli.connect(function() {
            mc_cli.add( GLOBAL_KEY, uid, { flags: 0, exptime: 0}, function(err, status) {
                if (!err) { 
                    console.log(status);
                }
                else {
                    console.log(err);
                }
            });
        });
    }
[...]

This code falls in the else with the following error:

{ type: 'CONNECTION_ERROR',
  description: 'Lost connection to server.' }

Basically what the code is doing is that since nobody set up the array of IDs connected, the first node to execute the code is the one in charge of doing it. I’m not showing the following code, which simply takes the list of IDs and adds its own. The error happens in the shown snippet. Now, the code that prints this error in the library is the following:

try {
    this.sock.write(command + crlf);
    if (value) {
      this.sock.write(value);
      this.sock.write(crlf);
    }
    this.queue.enqueue({ handler: handler, callback: callback });
}
catch (x) {
    callback({ type: 'CONNECTION_ERROR', description: 'Lost connection to server.' }, null);
}

Which is not so helpful, since I can’t understand what’s causing it.I’m wondering if what I’m doing is wrong. I’m using some nested thing that I’m used to with mongoDB, but I’m not sure I can do the same with memcached, especially this library. Has anyone with experience an idea on how to solve this issue? Thanks.

EDIT: I forgot to add the link to the library I’m using: overclocked/mc

  • 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-14T02:12:32+00:00Added an answer on June 14, 2026 at 2:12 am

    After a while trying to fight with this I realized that nested connections are possible, the error was not caused by that. I discovered that I was passing badly structured data to the .add() method. What it accepts is not something as simple as a Number or a String, but Buffers. So I had to convert every data I wanted to save like so:

    new Buffer(data)
    

    With default encoding (which I believe it’s utf8). I hope this is going to save somebody from hell. The main problem with my issue is that the error I received was not meaningful at all.

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

Sidebar

Related Questions

I have such file and I would like to replace $GLOBALS['SERVER_MEMCACHED']='localhost'; with $GLOBALS['SERVER_MEMCACHED']='mydomain.com'; using
I have a perl script that uses the CGI::Session::Drive::memcached, but I want to be
I would like to create a set of persistent objects that load their state
I have setup memcached (unix socket) for my django application. However it seems that
I want to use MemcacheDB instead of Memcached because I don't have a lot
I have site on Pyramid framework and want to cache with memcached. For testing
The setup is suppose I have 2 memcached servers, and 2 web servers to
I have several items on memcached that should expire 24h after the creation time.
Memcached is a great scalable cache layer but it have one big problem (for
I currently have about 650,000 items in memcached (430MB memory used) and the number

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.