2015-06-03 11:19:13 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "acl_cpp/acl_cpp_define.hpp"
|
|
|
|
|
#include <map>
|
|
|
|
|
#include "acl_cpp/stdlib/string.hpp"
|
|
|
|
|
#include "acl_cpp/session/session.hpp"
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
bool set(const char* name, const char* value);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
bool set(const char* name, const void* value, size_t len);
|
|
|
|
|
|
|
|
|
|
// <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>ֵ
|
|
|
|
|
const session_string* get_buf(const char* name);
|
|
|
|
|
|
|
|
|
|
// <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>ֵ
|
|
|
|
|
bool del(const char* name);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ി<EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool remove();
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ി<EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool get_attrs(std::map<string, session_string>& attrs);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ി<EFBFBD>麯<EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis <20><><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool set_attrs(const std::map<string, session_string>& attrs);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> session <20><> redis <20>ϵĻ<CFB5><C4BB><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
bool set_timeout(time_t ttl);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
redis_client_cluster& cluster_;
|
|
|
|
|
redis* command_;
|
|
|
|
|
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
|