-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkvserver.h
74 lines (59 loc) · 1.39 KB
/
kvserver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* File: kvserver.h
* Author: leo
*
* Created on 2013年6月1日, 下午5:36
*/
#ifndef KVSERVER_H
#define KVSERVER_H
#include<libmemcached/memcached.hpp>
#include<hiredis/async.h>
#include<hiredis/hiredis.h>
#include<string>
#include "logger.h"
#include "parse.h"
#include "core.h"
using namespace std;
class kvServer {
public:
virtual void getConnection(const char *ip, const int port) {
};
virtual bool set(const char *key, const char *val) {
};
virtual string get(const char *key) {
};
virtual void reConnection(void) {
};
kvServer() {
log = logger::getInstance();
};
protected:
logger *log;
char kvhost[15];
int kvport;
};
class redisServer : public kvServer {
public:
void getConnection(const char *ip, const int port);
void reConnection(void);
bool set(const char *key, const char *val);
string get(const char *key);
~redisServer();
private:
redisContext *redisConn;
redisReply *reply;
};
class memcachedSserver : public kvServer {
public:
void getConnection(const char *ip, const int port);
void reConnection(void);
bool set(const char *key, const char *val);
string get(const char *key);
~memcachedSserver();
private:
memcached_st *memcachedConn;
memcached_server_st *memcachedSvr;
memcached_return memcachedRet;
uint32_t cacheExpires;
};
#endif /* KVSERVER_H */