mco_disk_enable_connection_cache
启用或禁用连接缓存。
运行时为每个连接从页面池中“固定”预定义数量的页面。这被称为“连接缓存”。当事务将页面加载到页面池中,且从介质加载的页面总数小于连接缓存的大小时,运行时会确保这些页面保留在缓存中,直到事务提交或数据库连接断开。默认情况下,连接缓存的大小设置为四个页面。无法修改连接缓存的大小(也没有必要这样做)。 连接缓存默认启用。此 API 可启用或禁用连接缓存,并返回连接缓存的当前状态。
mco_bool mco_disk_enable_connection_cache(
/*IN*/ mco_db_h db,
/*IN*/ mco_bool enable
);
参数
db
mco_db_h
由 mco_db_connect()
建立的数据库句柄。
policy
mco_bool
一个 mco_bool
类型的值,MCO_YES
表示启用,MCO_NO
表示禁用。
返回
mco_bool
如果启用则值为 MCO_YES
,禁用则为 MCO_NO
。
示例
/* 应用程序代码片段 */
const char * dbname = "SimpleDb";
int main(int argc, char* argv[])
{
mco_db_h db;
MCO_RET rc;
mco_device_t dev[4];
mco_db_params_t db_params;
mco_disk_cache_info_t info;
...
rc = mco_db_open_dev( dbname, simple_get_dictionary(), dev, 4, &db_params );
if ( MCO_S_OK != rc )
{
rc = mco_db_connect( dbname, &db );
...
info = mco_disk_get_cache_info( db );
printf("\n\tCache info:\n"
"\t\tConnection hits:\t%d\n"
"\t\tCache hits:\t%d\n"
"\t\tCache misses:\t%d\n"
"\t\tAllocated pages:\t%d\n"
"\t\tUsed pages:\t%d\n"
"\t\tPinned pages:\t%d\n"
"\t\tModified pages:\t%d\n"
"\t\tDirty pages:\t%d\n"
"\t\tCopied pages:\t%d\n",
info->connection_cache_hits,
info->cache_hits,
info->cache_misses,
info->allocated_pages,
info->used_pages,
info->pinned_pages,
info->modified_pages,
info->dirty_pages,
info->copied_pages );
rc = mco_disk_flush( db );
...
}
}