~brianaker/libmemcached/1164440

« back to all changes in this revision

Viewing changes to lib/memcached_flush.c

  • Committer: patg@patg.net
  • Date: 2008-05-05 03:32:10 UTC
  • mfrom: (317.1.71)
  • Revision ID: patg@patg.net-20080505033210-yxv0us02t8lb44dy
Merge 477:75823cad36b7 with -r 476

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "common.h"
2
 
 
3
 
memcached_return memcached_flush(memcached_st *ptr, time_t expiration)
4
 
{
5
 
  unsigned int x;
6
 
  size_t send_length;
7
 
  memcached_return rc;
8
 
  char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
9
 
  LIBMEMCACHED_MEMCACHED_FLUSH_START();
10
 
 
11
 
  if (ptr->number_of_hosts == 0)
12
 
    return MEMCACHED_NO_SERVERS;
13
 
 
14
 
  for (x= 0; x < ptr->number_of_hosts; x++)
15
 
  {
16
 
    if (expiration)
17
 
      send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, 
18
 
                            "flush_all %llu\r\n", (unsigned long long)expiration);
19
 
    else
20
 
      send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, 
21
 
                            "flush_all\r\n");
22
 
 
23
 
    rc= memcached_do(&ptr->hosts[x], buffer, send_length, 1);
24
 
 
25
 
    if (rc == MEMCACHED_SUCCESS)
26
 
      (void)memcached_response(&ptr->hosts[x], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
27
 
  }
28
 
 
29
 
  LIBMEMCACHED_MEMCACHED_FLUSH_END();
30
 
  return MEMCACHED_SUCCESS;
31
 
}