~brianaker/libmemcached/embedded

« back to all changes in this revision

Viewing changes to libmemcached/memcached_flush.c

  • Committer: brian@gir-2.local
  • Date: 2008-03-10 15:04:41 UTC
  • mto: (317.6.1)
  • mto: This revision was merged to the branch mainline in revision 321.
  • Revision ID: brian@gir-2.local-20080310150441-jyhbjx6bwo46f6tg
Huge refactoring of directory structure.

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
  unlikely (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
}