From: Bert Hubert Date: Sun, 21 Jun 2009 10:57:54 +0000 (+0000) Subject: very rough stuff, but perhaps nice to look at already X-Git-Tag: rec-3.2~160 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9128f80f93a46429084e78d373e55486e6a341b;p=pdns very rough stuff, but perhaps nice to look at already git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1362 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/recursor_memcached.cc b/pdns/recursor_memcached.cc new file mode 100644 index 000000000..1b2243735 --- /dev/null +++ b/pdns/recursor_memcached.cc @@ -0,0 +1,86 @@ +#include +#include "statbag.hh" +#include "iputils.hh" +#include "recursor_memcached.hh" +#include + +using namespace std; +using boost::lexical_cast; + +MemcachedCommunicator::MemcachedCommunicator(const std::string& servers) +{ + d_socket=socket(AF_INET, SOCK_DGRAM, 0); + ComboAddress remote(servers, 11211); + if(connect(d_socket, (struct sockaddr*)&remote, remote.getSocklen()) < 0) + unixDie("connecting to remote memcached server '"+remote.toStringWithPort()+"'"); +} + +string MemcachedCommunicator::get(const std::string& key) +{ + cerr<<"Looking up: '"<(value.length())+"\r\n"+value+"\r\n"); + cerr<<"Message is: '"< +#include + +class MemcachedCommunicator +{ +public: + MemcachedCommunicator(const std::string& servers); + string get(const std::string& key); + void set(const std::string& key, const std::string& value); + struct UDPHeader + { + UDPHeader() + { + memset(this, 0, sizeof(*this)); + } + uint16_t id; + uint16_t seqNo; + uint16_t totalDgrams; + uint16_t mbZero; + }; + +private: + int d_socket; +}; +#endif