acl/lib_acl_cpp/include/acl_cpp/session/memcache_session.hpp

69 lines
2.0 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
#include "session.hpp"
2014-11-19 00:25:21 +08:00
#ifndef ACL_CLIENT_ONLY
2014-11-19 00:25:21 +08:00
namespace acl {
class memcache;
/**
* session <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> memcached <EFBFBD> session <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
class ACL_CPP_API memcache_session : public session
{
public:
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param cache_addr {const char*} memcached <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
* IP:PORT<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param prefix {const char*} <EFBFBD><EFBFBD> memcached <EFBFBD><EFBFBD>ļ<EFBFBD>ֵ<EFBFBD><EFBFBD>ǰ׺
* @param conn_timeout {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <EFBFBD>ij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param rw_timeout {int} <EFBFBD><EFBFBD> memcached ͨѶ<EFBFBD><EFBFBD> IO <EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param ttl {time_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param sid {const char*} session <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD> sid<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> session <EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>
* @param encode_key {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD> memcached <EFBFBD>ļ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
memcache_session(const char* cache_addr, int conn_timeout = 180,
int rw_timeout = 300, const char* prefix = NULL,
time_t ttl = 0, const char* sid = NULL, bool encode_key = true);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param cache {memcache*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
* @param auto_free {bool} <EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>Ϊ true ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* memcached_session <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷŴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cache <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD> memcached_session <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD> cache <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param ttl {time_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param sid {const char*} session <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD> sid<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> session <EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
memcache_session(memcache* cache, bool auto_free = false,
time_t ttl = 0, const char* sid = NULL);
~memcache_session(void);
// <20><><EFBFBD>ി<EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool get_attrs(std::map<string, session_string>& attrs);
2014-11-19 00:25:21 +08:00
// <20><><EFBFBD>ി<EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <20><><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
bool set_attrs(const std::map<string, session_string>& attrs);
2014-11-19 00:25:21 +08:00
// <20><><EFBFBD>ി<EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <20><>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool remove();
protected:
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> session <20><> memcached <20>ϵĻ<CFB5><C4BB><EFBFBD>ʱ<EFBFBD><CAB1>
bool set_timeout(time_t ttl);
2014-11-19 00:25:21 +08:00
private:
memcache* cache_;
bool auto_free_;
};
} // namespace acl
#endif // ACL_CLIENT_ONLY