libmemcached: add MEMCACHED_BEHAVIOR_META_PROTOCOL
[awesomized/libmemcached] / test / lib / MemcachedCluster.hpp
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 #include "common.hpp"
19 #include "Cluster.hpp"
20 #include "ReturnMatcher.hpp"
21
22 class MemcachedCluster {
23 public:
24 using behavior_t = pair<memcached_behavior_t, uint64_t>;
25 using behaviors_t = vector<behavior_t>;
26
27 Cluster cluster;
28 memcached_st memc{empty_memc};
29 ReturnMatcher returns{&memc};
30
31 MemcachedCluster();
32 explicit MemcachedCluster(Cluster &&cluster, behaviors_t to_set = {});
33 ~MemcachedCluster();
34
35 MemcachedCluster(const MemcachedCluster &) = delete;
36 MemcachedCluster &operator=(const MemcachedCluster &) = delete;
37
38 MemcachedCluster(MemcachedCluster &&mc) noexcept;
39 MemcachedCluster &operator=(MemcachedCluster &&mc) noexcept;
40
41 void enableBinaryProto(bool enable = true);
42 void enableMetaProto(bool enable = true);
43 void enableBuffering(bool enable = true);
44 void enableReplication();
45 void flush();
46
47 static MemcachedCluster mixed();
48 static MemcachedCluster network();
49 static MemcachedCluster socket();
50 static MemcachedCluster udp();
51
52 #if LIBMEMCACHED_WITH_SASL_SUPPORT
53 static MemcachedCluster sasl();
54 #endif
55
56 void killOneServer() const;
57 bool isGEVersion(uint8_t major, uint8_t minor = 0, uint8_t micro = 0);
58
59 private:
60 behaviors_t to_set;
61 static const memcached_st empty_memc;
62
63 void init();
64 };