本文整理汇总了C++中DB_ENV::get_cachesize方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::get_cachesize方法的具体用法?C++ DB_ENV::get_cachesize怎么用?C++ DB_ENV::get_cachesize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_ENV
的用法示例。
在下文中一共展示了DB_ENV::get_cachesize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
static DB_ENV *dict_db_new_env(const char *db_path)
{
VSTRING *db_home_buf;
DB_ENV *dbenv;
u_int32_t cache_size_gbytes;
u_int32_t cache_size_bytes;
int ncache;
if ((errno = db_env_create(&dbenv, 0)) != 0)
msg_fatal("create DB environment: %m");
#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 7)
if ((errno = dbenv->get_cachesize(dbenv, &cache_size_gbytes,
&cache_size_bytes, &ncache)) != 0)
msg_fatal("get DB cache size: %m");
if (cache_size_gbytes == 0 && cache_size_bytes < dict_db_cache_size) {
if ((errno = dbenv->set_cache_max(dbenv, cache_size_gbytes,
dict_db_cache_size)) != 0)
msg_fatal("set DB max cache size %d: %m", dict_db_cache_size);
if ((errno = dbenv->set_cachesize(dbenv, cache_size_gbytes,
dict_db_cache_size, ncache)) != 0)
msg_fatal("set DB cache size %d: %m", dict_db_cache_size);
}
#endif
/* XXX db_home is also the default directory for the .db file. */
db_home_buf = vstring_alloc(100);
if ((errno = dbenv->open(dbenv, sane_dirname(db_home_buf, db_path),
DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0)) != 0)
msg_fatal("open DB environment: %m");
vstring_free(db_home_buf);
return (dbenv);
}
示例2: TestSetCachesize
int TestSetCachesize(CuTest *ct) {
DB_ENV *dbenv;
int ncache;
u_int32_t a, b;
dbenv = NULL;
/* cache size: NOT reset at run-time. */
ENV
CuAssertTrue(ct, dbenv->set_cachesize(dbenv, 1, 131072, 3) == 0);
CuAssertTrue(ct, dbenv->open(dbenv,
TEST_ENV, DB_CREATE | DB_INIT_MPOOL, 0666) == 0);
CuAssertTrue(ct, dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
CuAssertTrue(ct, dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
CuAssertTrue(ct, a == 1 && b == 131072 && ncache == 3);
ENV
CuAssertTrue(ct, dbenv->set_cachesize(dbenv, 2, 262144, 1) == 0);
CuAssertTrue(ct, dbenv->open(dbenv, TEST_ENV, DB_JOINENV, 0666) == 0);
CuAssertTrue(ct, dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
CuAssertTrue(ct, a == 1 && b == 131072 && ncache == 3);
return (0);
}
示例3: sizeof
//.........这里部分代码省略.........
system("rm -rf TESTDIR; mkdir TESTDIR");
ENV
assert(dbenv->set_lk_detect(dbenv, DB_LOCK_MAXLOCKS) == 0);
assert(dbenv->open(dbenv,
"TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
assert(dbenv->get_lk_detect(dbenv, &v) == 0);
assert(v == DB_LOCK_MAXLOCKS);
ENV
assert(dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT) == 0);
assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
assert(dbenv->get_lk_detect(dbenv, &v) == 0);
assert(v == DB_LOCK_MAXLOCKS);
/* lk_max_locks: NOT reset at run-time. */
system("rm -rf TESTDIR; mkdir TESTDIR");
ENV
assert(dbenv->set_lk_max_locks(dbenv, 37) == 0);
assert(dbenv->open(dbenv,
"TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
assert(dbenv->get_lk_max_locks(dbenv, &v) == 0);
assert(v == 37);
ENV
assert(dbenv->set_lk_max_locks(dbenv, 63) == 0);
assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
assert(dbenv->get_lk_max_locks(dbenv, &v) == 0);
assert(v == 37);
/* lk_max_lockers: NOT reset at run-time. */
system("rm -rf TESTDIR; mkdir TESTDIR");
ENV
assert(dbenv->set_lk_max_lockers(dbenv, 37) == 0);
assert(dbenv->open(dbenv,
"TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
assert(dbenv->get_lk_max_lockers(dbenv, &v) == 0);
assert(v == 37);
ENV
assert(dbenv->set_lk_max_lockers(dbenv, 63) == 0);
assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
assert(dbenv->get_lk_max_lockers(dbenv, &v) == 0);
assert(v == 37);
/* lk_max_objects: NOT reset at run-time. */
system("rm -rf TESTDIR; mkdir TESTDIR");
ENV
assert(dbenv->set_lk_max_objects(dbenv, 37) == 0);
assert(dbenv->open(dbenv,
"TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
assert(dbenv->get_lk_max_objects(dbenv, &v) == 0);
assert(v == 37);
ENV
assert(dbenv->set_lk_max_objects(dbenv, 63) == 0);
assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
assert(dbenv->get_lk_max_objects(dbenv, &v) == 0);
assert(v == 37);
/* lock timeout: reset at run-time. */
system("rm -rf TESTDIR; mkdir TESTDIR");
ENV
assert(dbenv->set_timeout(dbenv, 37, DB_SET_LOCK_TIMEOUT) == 0);
assert(dbenv->open(dbenv,
"TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_LOCK_TIMEOUT) == 0);
assert(timeout == 37);
ENV
assert(dbenv->set_timeout(dbenv, 63, DB_SET_LOCK_TIMEOUT) == 0);
assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_LOCK_TIMEOUT) == 0);
assert(timeout == 63);
/* txn timeout: reset at run-time. */
system("rm -rf TESTDIR; mkdir TESTDIR");
ENV
assert(dbenv->set_timeout(dbenv, 37, DB_SET_TXN_TIMEOUT) == 0);
assert(dbenv->open(dbenv,
"TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
assert(timeout == 37);
ENV
assert(dbenv->set_timeout(dbenv, 63, DB_SET_TXN_TIMEOUT) == 0);
assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
assert(timeout == 63);
/* cache size: NOT reset at run-time. */
system("rm -rf TESTDIR; mkdir TESTDIR");
ENV
assert(dbenv->set_cachesize(dbenv, 1, 131072, 3) == 0);
assert(dbenv->open(dbenv,
"TESTDIR", DB_CREATE | DB_INIT_MPOOL, 0666) == 0);
assert(dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
assert(dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
assert(a == 1 && b == 131072 && ncache == 3);
ENV
assert(dbenv->set_cachesize(dbenv, 2, 262144, 1) == 0);
assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
assert(dbenv->get_cachesize(dbenv, &a, &b, &ncache) == 0);
assert(a == 1 && b == 131072 && ncache == 3);
return (0);
}