diff --git a/lib_acl_cpp/changes.txt b/lib_acl_cpp/changes.txt index 9c9b96d76..b4316d626 100644 --- a/lib_acl_cpp/changes.txt +++ b/lib_acl_cpp/changes.txt @@ -1,6 +1,12 @@ 修改历史列表: ------------------------------------------------------------------------ +317) 2015.6.22 +317.1) feature: dbuf_pool 类增加了 dbuf_reset 方法,可以重复使用该类对象 +317.2) performance: redis_command 类当每一个命令处理完毕后不再释放内存池对象, +而是复用之 +317.3) bugfix: redis_zset 类有一处在调用 sizeof 时未 -1 + 316) 2015.6.17 316.1) feature: 增加了类 thread_queue 用来处理线程消息队列 diff --git a/lib_acl_cpp/include/acl_cpp/stdlib/dbuf_pool.hpp b/lib_acl_cpp/include/acl_cpp/stdlib/dbuf_pool.hpp index 6b8bbb9db..58f53d559 100644 --- a/lib_acl_cpp/include/acl_cpp/stdlib/dbuf_pool.hpp +++ b/lib_acl_cpp/include/acl_cpp/stdlib/dbuf_pool.hpp @@ -17,6 +17,11 @@ public: dbuf_pool(size_t block_size = 8192); ~dbuf_pool(); + /** + * 重置内存池的状态以便于重复使用该内存池对象 + */ + void dbuf_reset(); + /** * 分配指定长度的内存 * @param len {size_t} 需要分配的内存长度,当内存比较小时(小于构造函数中的 diff --git a/lib_acl_cpp/src/redis/redis_command.cpp b/lib_acl_cpp/src/redis/redis_command.cpp index 8a9b15ddf..b296b5e9f 100644 --- a/lib_acl_cpp/src/redis/redis_command.cpp +++ b/lib_acl_cpp/src/redis/redis_command.cpp @@ -113,8 +113,7 @@ void redis_command::clear(bool save_slot /* = false */) { if (used_ > 0) { - delete pool_; - pool_ = NEW dbuf_pool(); + pool_->dbuf_reset(); result_ = NULL; } if (!save_slot) diff --git a/lib_acl_cpp/src/redis/redis_zset.cpp b/lib_acl_cpp/src/redis/redis_zset.cpp index f9f6805ce..d72adf431 100644 --- a/lib_acl_cpp/src/redis/redis_zset.cpp +++ b/lib_acl_cpp/src/redis/redis_zset.cpp @@ -1010,7 +1010,7 @@ int redis_zset::zrangebylex(const char* key, const char* min, const char* max, size_t argc = 4; argv[0] = "ZRANGEBYLEX"; - lens[0] = sizeof("ZRANGEBYLEX"); + lens[0] = sizeof("ZRANGEBYLEX") - 1; argv[1] = key; lens[1] = strlen(key); diff --git a/lib_acl_cpp/src/stdlib/dbuf_pool.cpp b/lib_acl_cpp/src/stdlib/dbuf_pool.cpp index 74e3f66ee..2f20e89a3 100644 --- a/lib_acl_cpp/src/stdlib/dbuf_pool.cpp +++ b/lib_acl_cpp/src/stdlib/dbuf_pool.cpp @@ -14,6 +14,11 @@ dbuf_pool::~dbuf_pool() acl_dbuf_pool_destroy(pool_); } +void dbuf_pool::dbuf_reset() +{ + acl_dbuf_pool_reset(pool_); +} + void* dbuf_pool::dbuf_alloc(size_t len) { return acl_dbuf_pool_alloc(pool_, len);