mco_disk_get_cache_info
获取运行时磁盘管理器缓存统计信息。
此函数允许应用程序获取运行时磁盘管理器缓存统计信息,这些信息以结构体 mco_disk_cache_info_t
的形式呈现,包括缓存命中和缓存未命中。当数据库运行时所需的地址或数据在缓存中找到,而无需从存储介质中检索时,即发生缓存命中。
例如,此信息可用于微调应用程序的缓存策略。
mco_disk_cache_info_t* mco_disk_get_cache_info(
/*IN*/ mco_db_h db
);
参数
db
mco_db_h
由 mco_db_connect()
建立的数据库句柄。
返回
mco_disk_cache_info_t
当前运行时磁盘管理器缓存统计信息在结构体 mco_disk_cache_info_t
中
示例
/* 应用程序代码片段 */
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 );
...
}
}
文件
头文件:
mco.h
源文件:
mcodisk.c
库:
libmcovtdsk.a
头文件:
mco.h
源文件:
mcovtmem.c
库:
libmcovtmem.a