libmoost
/home/mhx/git/github/libmoost/include/moost/kvstore/detail/kyoto_tycoon_connection_linux.h
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 
00029 
00030 
00031 #ifndef MOOST_KVSTORE_DETAIL_KYOTO_TYCOON_CONNECTION_LINUX_H
00032 #define MOOST_KVSTORE_DETAIL_KYOTO_TYCOON_CONNECTION_LINUX_H
00033 
00034 #include <string>
00035 
00036 #include <boost/shared_ptr.hpp>
00037 
00038 #include "../i_kyoto_tycoon_connection.h"
00039 
00040 namespace kyototycoon {
00041    class RemoteDB;
00042 }
00043 
00044 namespace moost { namespace kvstore { namespace detail {
00045 
00046 class KyotoTycoonConnection : public IKyotoTycoonConnection
00047 {
00048 public:
00049 
00050    KyotoTycoonConnection() : isOpen_(false) { }
00051 
00052    virtual ~KyotoTycoonConnection();
00053 
00054    virtual void open(const std::string& host, int port, int timeoutMs);
00055 
00056    virtual void close();
00057 
00058 public:
00059 
00060    // native store methods
00061 
00062    // return value is a C-style string of length vsize
00063    // (not including the trailing null byte)
00064    virtual boost::shared_array<char> get(const void* pkey, size_t ksize, size_t& vsize) const;
00065 
00066    // throws on failure
00067    virtual void set(const void* pkey, size_t ksize, const void* pval, size_t vsize) const;
00068 
00069    // throws on failure
00070    virtual void cache(const void* pkey, size_t ksize, const void* pval, size_t vsize, boost::int64_t expirySecs) const;
00071 
00072 private:
00073 
00074    void throw_kt_exception(const std::string& msg) const;
00075 
00076    void assert_data_store_open() const;
00077 
00078 private:
00079 
00080    boost::shared_ptr<kyototycoon::RemoteDB> pDb_;
00081    bool isOpen_;
00082 };
00083 
00084 }}}  // end namespace
00085 
00086 #endif