Bug fix in documentation Tim found.
[awesomized/libmemcached] / libmemcached / memcached_get.c
index a2f7716d485d3e190b694899ef8074a487229c92..34fcb4ea974a1ad2729e000ff2fac2624558d160 100644 (file)
@@ -51,22 +51,28 @@ char *memcached_get_by_key(memcached_st *ptr,
       /* On all failure drop to returning NULL */
       if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED)
       {
-        uint8_t latch; /* We use latch to track the state of the original socket */
-
         if (rc == MEMCACHED_BUFFERED)
         {
+          uint8_t latch; /* We use latch to track the state of the original socket */
           latch= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS);
           if (latch == 0)
             memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
-        }
 
-        rc= memcached_set(ptr, key, key_length, 
-                          memcached_result_value(&ptr->result),
-                          memcached_result_length(&ptr->result),
-                          0, memcached_result_flags(&ptr->result));
+          rc= memcached_set(ptr, key, key_length, 
+                            memcached_result_value(&ptr->result),
+                            memcached_result_length(&ptr->result),
+                            0, memcached_result_flags(&ptr->result));
 
-        if (rc == MEMCACHED_BUFFERED && latch == 0)
-          memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0);
+          if (rc == MEMCACHED_BUFFERED && latch == 0)
+            memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0);
+        }
+        else
+        {
+          rc= memcached_set(ptr, key, key_length, 
+                            memcached_result_value(&ptr->result),
+                            memcached_result_length(&ptr->result),
+                            0, memcached_result_flags(&ptr->result));
+        }
 
         if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED)
         {
@@ -180,6 +186,17 @@ memcached_return memcached_mget_by_key(memcached_st *ptr,
       WATCHPOINT_ASSERT(ptr->hosts[server_key].cursor_active == 1);
     }
 
+    /* Only called when we have a prefix key */
+    if (ptr->prefix_key[0] != 0)
+    {
+      if ((memcached_io_write(&ptr->hosts[server_key], ptr->prefix_key, ptr->prefix_key_length, 0)) == -1)
+      {
+        memcached_server_response_reset(&ptr->hosts[server_key]);
+        rc= MEMCACHED_SOME_ERRORS;
+        continue;
+      }
+    }
+
     if ((memcached_io_write(&ptr->hosts[server_key], keys[x], key_length[x], 0)) == -1)
     {
       memcached_server_response_reset(&ptr->hosts[server_key]);