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

65 lines
2.0 KiB
C++
Raw Normal View History

2014-11-19 00:25:21 +08:00
#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include "acl_cpp/session/session.hpp"
namespace acl {
class memcache;
/**
* session <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> memcached <EFBFBD> session <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
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>
*/
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>
*/
memcache_session(memcache* cache, bool auto_free = false,
time_t ttl = 0, const char* sid = NULL);
~memcache_session(void);
private:
// <20><><EFBFBD>ി<EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
virtual bool get_data(const char* sid, string& buf);
// <20><><EFBFBD>ി<EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <20><><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
virtual bool set_data(const char* sid, const char* buf,
size_t len, time_t ttl);
// <20><><EFBFBD>ി<EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcached <20><>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
virtual bool del_data(const char* sid);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> session <20>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵĻ<CFB5><C4BB><EFBFBD>ʱ<EFBFBD><CAB1>
virtual bool set_timeout(const char* sid, time_t ttl);
private:
memcache* cache_;
bool auto_free_;
};
} // namespace acl