#include <mysql_manager.hpp>
|
| mysql_manager (time_t idle_ttl=120) |
|
| ~mysql_manager () |
|
mysql_manager & | add (const char *dbaddr, const char *dbname, const char *dbuser, const char *dbpass, size_t dblimit=64, unsigned long dbflags=0, bool auto_commit=true, int conn_timeout=60, int rw_timeout=60, const char *charset="utf8") |
|
mysql_manager & | add (const mysql_conf &conf) |
|
| connect_manager (void) |
|
virtual | ~connect_manager (void) |
|
void | bind_thread (bool yes) |
|
void | init (const char *default_addr, const char *addr_list, size_t count, int conn_timeout=30, int rw_timeout=30) |
|
void | set (const char *addr, size_t count, int conn_timeout=30, int rw_timeout=30) |
|
const conn_config * | get_config (const char *addr, bool use_first=false) |
|
void | set_retry_inter (int n) |
|
void | set_idle_ttl (time_t ttl) |
|
void | set_check_inter (int n) |
|
void | remove (const char *addr) |
|
connect_pool * | get (const char *addr, bool exclusive=true, bool restore=false) |
|
virtual connect_pool * | peek (void) |
|
virtual connect_pool * | peek (const char *key, bool exclusive=true) |
|
void | lock (void) |
|
void | unlock (void) |
|
std::vector< connect_pool * > & | get_pools (void) |
|
size_t | check_idle (size_t step, size_t *left=NULL) |
|
size_t | size (void) const |
|
connect_pool * | get_default_pool (void) |
|
void | statistics (void) |
|
bool | start_monitor (connect_monitor *monitor) |
|
connect_monitor * | stop_monitor (bool graceful=true) |
|
void | set_pools_status (const char *addr, bool alive) |
|
|
connect_pool * | create_pool (const char *addr, size_t count, size_t idx) |
|
void | set_service_list (const char *addr_list, int count, int conn_timeout, int rw_timeout) |
|
conns_pools & | get_pools_by_id (unsigned long id) |
|
connect_pool * | create_pool (const conn_config &cf, size_t idx) |
|
void | create_pools_for (pools_t &pools) |
|
void | remove (pools_t &pools, const char *addr) |
|
void | set_status (pools_t &pools, const char *addr, bool alive) |
|
unsigned long | get_id (void) const |
|
void | get_key (const char *addr, string &key) |
|
void | get_addr (const char *key, string &addr) |
|
connect_pool * | add_pool (const char *addr) |
|
| noncopyable () |
|
| ~noncopyable () |
|
◆ mysql_manager()
acl::mysql_manager::mysql_manager |
( |
time_t |
idle_ttl = 120 | ) |
|
◆ ~mysql_manager()
acl::mysql_manager::~mysql_manager |
( |
| ) |
|
◆ add() [1/2]
mysql_manager& acl::mysql_manager::add |
( |
const char * |
dbaddr, |
|
|
const char * |
dbname, |
|
|
const char * |
dbuser, |
|
|
const char * |
dbpass, |
|
|
size_t |
dblimit = 64 , |
|
|
unsigned long |
dbflags = 0 , |
|
|
bool |
auto_commit = true , |
|
|
int |
conn_timeout = 60 , |
|
|
int |
rw_timeout = 60 , |
|
|
const char * |
charset = "utf8" |
|
) |
| |
添加一个数据库实例方法一
- 参数
-
dbaddr | {const char*} mysql 服务器地址,格式:IP:PORT, 在 UNIX 平台下可以为 UNIX 域套接口 |
dbname | {const char*} 数据库名 |
dbuser | {const char*} 数据库用户 |
dbpass | {const char*} 数据库用户密码 |
dblimit | {size_t} 数据库连接池的最大连接数限制 |
dbflags | {unsigned long} mysql 标记位 |
auto_commit | {bool} 是否自动提交 |
conn_timeout | {int} 连接数据库超时时间(秒) |
rw_timeout | {int} 与数据库通信时的IO时间(秒) |
charset | {const char*} 连接数据库时的字符集 |
- 返回
- {mysql_manager&}
◆ add() [2/2]
◆ create_pool()
connect_pool* acl::mysql_manager::create_pool |
( |
const char * |
addr, |
|
|
size_t |
count, |
|
|
size_t |
idx |
|
) |
| |
|
protectedvirtual |
基类 connect_manager 虚函数的实现
- 参数
-
addr | {const char*} 服务器监听地址,格式:ip:port |
count | {size_t} 连接池的大小限制,该值为 0 时则没有限制 |
idx | {size_t} 该连接池对象在集合中的下标位置(从 0 开始) |
- 返回
- {connect_pool*} 返回创建的连接池对象
实现了 acl::connect_manager.
该类的文档由以下文件生成: