Well, I have been able to figure out the functions to be used. In the 
documentation it is mentioned that we should call memcached_fetch_result() 
in a loop until it results NULL.
I am however unable to fetch all the key-value pairs that I need. Instead 
each iteration of the memcached_fetch_result() loop returns the same values 
(i.e. the first key-value pair in my dataset). Is there some pointer or 
index that needs to be incremented at each iteration of the loop??

        rc = memcached_mget(memc, (const char* const*)keyArray, (const 
size_t*)keyLen, nSubsetSize);
        if (rc != MEMCACHED_SUCCESS)
        {
            printf("\nmecached_mget FAILED. %s\n", memcached_strerror(memc, 
rc));

            for(i = 0; i < nSubsetSize; i++)
            {
                free(keyArray[i]);
            }
            free(keyArray);
            free(keyLen);
         
            return (1);    
        }

        results = NULL;
        results = memcached_result_create(memc, &results_obj);
        if (NULL == results)
        {
            printf("\nmecached_mget FAILED.\n");

            for(i = 0; i < nSubsetSize; i++)
            {
                free(keyArray[i]);
            }
            free(keyArray);
            free(keyLen);

            return (1);
        }

        int iTemp = 0;
        while((results = memcached_fetch_result(memc, &results_obj, &rc)) != 
NULL)
        {
            if (rc != MEMCACHED_SUCCESS)
            {
                printf("\nmemcached_fetch_result FAILED. %s\n", 
memcached_strerror(memc, rc));

                for(i = 0; i < nSubsetSize; i++)
                {
                    free(keyArray[i]);
                }
                free(keyArray);
                free(keyLen);

                return (1);    
            }

            printf("key %d: (%s). Result value (%s)\n", iTemp++, 
memcached_result_key_value(results), memcached_result_value(results));
        }

        memcached_result_free(results);
        for(i = 0; i < nSubsetSize; i++)
        {
            free(keyArray[i]);
        }
        free(keyArray);
        free(keyLen);



On Friday, September 2, 2016 at 11:52:01 AM UTC-5, student wrote:
>
> Hi,
>
> I have used memcached_mget() to fetch multiple key-value pairs from the 
> server and according to the documentation I am supposed to use 
> memcached_fetch_result() to get the retrieved results.
> I now want to fetch the individual key-value pairs obtained in the result. 
> How should I go about this because the documentation regarding this is a 
> bit unclear to me.
> Following is a snippet of the relevant sections of my code.
>         rc = memcached_mget(memc, keyArray, keyLen, nSubsetSize);
>         if (rc != MEMCACHED_SUCCESS)
>         {
>             printf("\nmecached_mget FAILED. %s\n", memcached_strerror(memc
> , rc));
>
>             for(i = 0; i < nSubsetSize; i++)
>             {
>                 free(keyArray[i]);
>             }
>             free(keyArray);
>             free(keyLen);
>             
>             return (1);    
>         }
>
>         results = NULL;
>         results= memcached_result_create(memc, &results_obj);
>         if (NULL == results)
>         {
>             printf("\nmecached_mget FAILED.\n");
>
>             for(i = 0; i < nSubsetSize; i++)
>             {
>                 free(keyArray[i]);
>             }
>             free(keyArray);
>             free(keyLen);
>
>             return (1);    
>         }
>
>         while((results = memcached_fetch_result(memc, &results_obj, &rc)) 
> != NULL)
>         {
>             //Code to print individual key-value pairs???
>         }
>
>
>

-- 

--- 
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 memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to