I am also having a problem in setting out the timeout value for the
memcached. I am using the following connection string for setting the
timeout value of 200ms.
const char* config_string = "--SERVER=127.0.0.1:22122 --BINARY-PROTOCOL
--CONNECT-TIMEOUT=200 --SND-TIMEOUT=200 --RCV-TIMEOUT=200";
Now in order to test the timeout values, I opened up a TCP socket over port
22122 pretending to be a fake memcached server. However, the server took
around 10 seconds to timeout. Can anyone tell me what is the problem in
this case? I am attaching the source file with this message.
On Wednesday, 18 February 2015 14:49:46 UTC+5, Muhammad Junaid Muzammil
wrote:
>
> Thanks for your reply. Yes I haven't enabled binary protocol in my
> application. This has been one of the reasons why I wasn't getting the
> response.
>
>
> On Wednesday, 18 February 2015 13:26:57 UTC+5, Ryan McElroy wrote:
>>
>> I'm not an expert on libmemcached, but I took a quick look at the source
>> code of it and it looks like it defaults to the ascii protocol. The ascii
>> protocol only allows for printable characters in keys:
>>
>> At any rate, this would probably be a lot more apparent if you actually
>> checked the value of the call to memcached_set() -- I bet that's failing.
>>
>> To solve this problem, you can probably turn on the binary protocol or
>> use keys without control characters. Consult the libmemcached documentation
>> on how to turn on the binary protocol if that's the route you want to go.
>>
>> On Tue, Feb 17, 2015 at 10:58 PM, Muhammad Junaid Muzammil <
>> [email protected]> wrote:
>>
>>> Hello,
>>>
>>> I am using C memcached client in one of my applications. I am using
>>> different ASCII characters as a key for storing in memcached. However, when
>>> I retrieve data using memcached_get() it is always returning null.
>>>
>>> I have attached the source file for reference.
>>>
>>> Regards,
>>> Junaid.
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "memcached" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
---
You received this message because you are subscribed to the Google Groups
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libmemcached/memcached.h>
int main() {
const char* config_string = "--SERVER=127.0.0.1:22122 --BINARY-PROTOCOL --CONNECT-TIMEOUT=200 --SND-TIMEOUT=200 --RCV-TIMEOUT=200";
memcached_st* memc = memcached(config_string, strlen(config_string));
char key[]= "\x13\x05\x07\x03\x01";
char* value = "Saved Value";
size_t value_len = 100;
uint32_t flags;
memcached_set(memc, key, strlen(key), value, strlen(value), 6, 0);
size_t return_value;
memcached_return_t error;
char* datavalue = memcached_get(memc, key, strlen(key), &return_value, &flags, &error);
printf("len[%d] value[%s] error[%d]", return_value, datavalue, error);
memcached_free(memc);
}