memcached_delete.pod\\r
memcached_set.pod\\r
memcached_version.pod\\r
- memflush.pod\r
+ memflush.pod\\r
+ memcached_flush_buffers.pod\r
\r
man_MANS = libmemcached.3\\r
libmemcached_examples.3\\r
memcached_quit.3\\r
memcached_verbosity.3\\r
memcached_lib_version.3\\r
- memcached_version.3\r
+ memcached_version.3\\r
+ memcached_flush_buffers.3\r
\r
libmemcached.3: libmemcached.pod \r
@POD2MAN@ -c "libmemcached" -r "" -s 3 libmemcached.pod > libmemcached.3\r
memcached_lib_version.3: memcached_version.pod\r
@POD2MAN@ -c "libmemcached" -r "" -s 3 memcached_version.pod > memcached_lib_version.3\r
\r
+memcached_flush_buffers.3: memcached_flush_buffers.pod\r
+ @POD2MAN@ -c "libmemcached" -r "" -s 3 memcached_flush_buffers.pod > memcached_flush_buffers.3\r
+\r
memcp.1: memcp.pod\r
@POD2MAN@ -c "libmemcached" -r "" -s 1 memcp.pod > memcp.1\r
\r
podchecker memcached_set.pod\r
podchecker memcached_version.pod\r
podchecker memflush.pod\r
-\r
+ podchecker memcached_flush_buffers.pod\r
\r
html:\r
pod2htmltree "/libmemcached" .\r
=item MEMCACHED_BEHAVIOR_NOREPLY
Set this value to specify that you really don't care about the result
-from your storage commands (set, add, replace, append, prepend). With
-this flag enabled, each storage request will be sent immediately to the
-server overriding any setting of MEMCACHED_BEHAVIOR_BUFFER_REQUESTS.
+from your storage commands (set, add, replace, append, prepend).
=back
--- /dev/null
+=head1 NAME
+
+memcached_flush_buffers
+
+=head1 LIBRARY
+
+C Client Library for memcached (libmemcached, -lmemcached)
+
+=head1 SYNOPSIS
+
+ #include <memcached.h>
+
+ memcached_return
+ memcached_flush_buffers (memcached_st *ptr);
+
+=head1 DESCRIPTION
+
+memcached_flush_buffers() is used in conjunction with
+MEMCACHED_BEHAVIOR_BUFFER_REQUESTS (see memcached_behavior(3)) to flush
+all buffers by sending the buffered commands to the server for processing..
+
+=head1 RETURN
+
+A value of type C<memcached_return> is returned
+On success that value will be C<MEMCACHED_SUCCESS>.
+Use memcached_strerror() to translate this value to a printable string.
+
+=head1 HOME
+
+To find out more information please check:
+L<http://tangent.org/552/libmemcached.html>
+
+=head1 AUTHOR
+
+Trond Norbye, E<lt>trond.norbye@sun.comE<gt>
+
+=head1 SEE ALSO
+
+memcached(1) libmemcached(3) memcached_strerror(3) memcached_behavior(3)
+
+=cut
+
memcached_hosts.c \
memcached_io.c \
memcached_purge.c \
+ memcached_flush_buffers.c \
md5.c \
memcached_key.c \
memcached_quit.c \
--- /dev/null
+#include "common.h"
+#include "memcached_io.h"
+
+memcached_return memcached_flush_buffers(memcached_st *mem)
+{
+ memcached_return ret= MEMCACHED_SUCCESS;
+
+ for (int x= 0; x < mem->number_of_hosts; ++x)
+ if (memcached_io_write(&mem->hosts[x], NULL, 0, 1) == -1)
+ ret= MEMCACHED_SOME_ERRORS;
+
+ return ret;
+}
if (ptr->flags & MEM_NOREPLY)
{
if (memcached_io_write(&ptr->hosts[server_key], " noreply\r\n",
- 10, 1) == -1)
+ 10, to_write) == -1)
{
rc= MEMCACHED_WRITE_FAILURE;
goto error;
}
memcached_server_response_decrement(&ptr->hosts[server_key]);
- return MEMCACHED_SUCCESS;
+ return (to_write == 0) ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS;
}
if ((sent_length= memcached_io_write(&ptr->hosts[server_key], "\r\n", 2, to_write)) == -1)
flush= ((server->root->flags & MEM_BUFFER_REQUESTS) && verb == SET_OP) ? 0 : 1;
- /* The binary protocol does not implement NOREPLY right now, so I need to
- * parse the return message from the server. The problem we tried to solve
- * is the fact that the async mode will buffer commands, and if we issue a
- * lot of sets followed by a get we have to flush the send buffer before we
- * can send the get command (and all those commands have to be executed).
- * The workaround for the binary is that we send the command, but we await
- * parsing of the result message until we really need to do it..
- */
- if (server->root->flags & MEM_NOREPLY)
- flush=1;
-
/* write the header */
if ((memcached_do(server, (const char*)request.bytes, send_length, 0) != MEMCACHED_SUCCESS) ||
(memcached_io_write(server, key, key_length, 0) == -1) ||
return MEMCACHED_WRITE_FAILURE;
}
- if (flush == 0 || server->root->flags & MEM_NOREPLY)
+ if (flush == 0)
return MEMCACHED_BUFFERED;
return memcached_response(server, NULL, 0, NULL);
else
assert(no_msg == 0);
+ assert(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS);
return MEMCACHED_SUCCESS;
}