2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2015-06-03 11:19:13 +08:00
|
|
|
|
#include <map>
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/string.hpp"
|
|
|
|
|
#include "session.hpp"
|
2015-06-03 11:19:13 +08:00
|
|
|
|
|
2019-05-18 21:19:21 +08:00
|
|
|
|
#ifndef ACL_CLIENT_ONLY
|
|
|
|
|
|
2015-06-03 11:19:13 +08:00
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class redis;
|
|
|
|
|
class redis_client_cluster;
|
|
|
|
|
|
|
|
|
|
class ACL_CPP_API redis_session : public session
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
redis_session(redis_client_cluster& cluster, size_t max_conns,
|
|
|
|
|
time_t ttl = 0, const char* sid = NULL);
|
|
|
|
|
~redis_session();
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>ֵ
|
2015-06-03 11:19:13 +08:00
|
|
|
|
bool set(const char* name, const char* value);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>ֵ
|
2015-06-03 11:19:13 +08:00
|
|
|
|
bool set(const char* name, const void* value, size_t len);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><><EFBFBD><EFBFBD><EFBFBD>˵Ĺ<CBB5>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>ö<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>Ե<EFBFBD>ֵ
|
2015-06-03 11:19:13 +08:00
|
|
|
|
const session_string* get_buf(const char* name);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><><EFBFBD><EFBFBD><EFBFBD>˵Ĺ<CBB5>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
2015-06-03 11:19:13 +08:00
|
|
|
|
bool del(const char* name);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD>ി<EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-06-03 11:19:13 +08:00
|
|
|
|
bool remove();
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD>ി<EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-06-03 11:19:13 +08:00
|
|
|
|
bool get_attrs(std::map<string, session_string>& attrs);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2016-02-25 19:57:02 +08:00
|
|
|
|
bool get_attrs(const std::vector<string>& names,
|
|
|
|
|
std::vector<session_string>& values);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD>ി<EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
|
2015-06-03 11:19:13 +08:00
|
|
|
|
bool set_attrs(const std::map<string, session_string>& attrs);
|
|
|
|
|
|
|
|
|
|
protected:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> session <20><> redis <20>ϵĻ<CFB5><C4BB><EFBFBD>ʱ<EFBFBD><CAB1>
|
2015-06-03 11:19:13 +08:00
|
|
|
|
bool set_timeout(time_t ttl);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
redis_client_cluster& cluster_;
|
|
|
|
|
redis* command_;
|
2017-07-20 10:59:28 +08:00
|
|
|
|
// size_t max_conns_;
|
2015-06-03 22:41:24 +08:00
|
|
|
|
std::map<string, session_string*> buffers_;
|
2015-06-03 11:19:13 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
|
|
|
|
#endif // ACL_CLIENT_ONLY
|