#ifndef __C_REDIS_ACCESS_H__ #define __C_REDIS_ACCESS_H__ #pragma once #include #include #include #include #include #ifdef _REDIS_ACCESS #include "hiredis.h" #endif using namespace std; #define REDIS_ACCESS_SUCCESS 1 #define REDIS_ACCESS_FAIL -1 class CRedisAccess { public: CRedisAccess(); int Connect(const char *ip, int port, string& err_str); int disConnect(); int setString(const string &key, const string &value, string& err_str); int setString(const string & data, string& err_str); int getString(const string & key, string & value, string& err_str); int freeReply(); bool isDisconnected(); private: #ifdef _REDIS_ACCESS redisContext * _context; redisReply * _reply; #endif }; #endif