YD_RedisClient.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #if defined(_MSC_VER) || defined(WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32)
  3. #ifdef _OCC_P_REDISCLIENT_SDK
  4. #define _OCC_P_REDISCLIENT_API __declspec(dllexport)
  5. #else
  6. #define _OCC_P_REDISCLIENT_API __declspec(dllimport)
  7. #endif
  8. #else //Linux
  9. #ifdef _OCC_P_REDISCLIENT_SDK
  10. #define _OCC_P_REDISCLIENT_API __attribute__ ((visibility("default")))
  11. #else
  12. #define _OCC_P_REDISCLIENT_API __attribute__ ((visibility("default")))
  13. #endif
  14. #endif //WIN32|WIN64
  15. #include <vector>
  16. #include <string>
  17. #include "RedisDefine.h"
  18. class xhRedisClient;
  19. class _OCC_P_REDISCLIENT_API YD_RedisClient
  20. {
  21. public:
  22. YD_RedisClient();
  23. ~YD_RedisClient();
  24. public:
  25. int StartRedis(const std::string& Str_IP, int nPort); //连接Redis数据库
  26. int Stop(); //断开Redis数据库
  27. int Set(const std::string& strKey, const std::string& strValue); //设置-Key和Value
  28. int Set(const std::vector<std::pair<std::string, std::string>> & vcmd); //设置-vcmd
  29. int Set(const ST_REDISBUFFER & RedisBuffer); //设置-RedisBuffer
  30. int Set(const std::vector<ST_REDISBUFFER> & vcmd); //设置-vcmd
  31. int lSet(const std::string& strKey, const std::string& strValue,int nIndex);//设置-Key和Value和nIndex
  32. int lPush(const std::string& strKey, const std::string& strValue); //按照List存入数据库
  33. int lRange(const std::string& strKey, std::string& strValue); //按照List存入数据库
  34. int Get(const std::string& strKey, std::string& strValue); //读取-数据库中Key和Value
  35. int Get(std::vector<std::pair<std::string, std::string>> & vcmd); //读取-vcmd
  36. int Get(ST_REDISBUFFEROUT& RedisBuffer); //读取-RedisBuffer
  37. int Get(std::vector<ST_REDISBUFFEROUT>& vcmd); //读取-vcmd
  38. int DoCmd(const std::string& strCmd, std::string& strReply); //执行指令
  39. private:
  40. xhRedisClient* m_pClient;
  41. };