zoukankan      html  css  js  c++  java
  • Enterprise Library: Configuration Application Block

    ConfigurationBuilder类用来返回存储区中当前配置设置。基于性能的考虑,当每一个配置节信息从存储区读取后,ConfigurationBuilder将缓存该配置信息。只要缓存信息与底层存储区数据保持一致,缓存信息将返回给应用程序。当Storage Provider检测到配置设置发生变化时,它将触发一个事件,表示该配置节发生了变化。当ConfigurationBuilder接受到该事件时,将从缓存中清除该配置节信息。这样,在应用程序下次尝试读取该节配置信息时,ConfigurationBuilder将从存储区直接读取新的配置信息。

    当使用XML文件的Storage Provider时,从配置文件发生改变到检测到该改变大约存在1500毫秒的延迟。ConfigurationChangeFileWatcher对象每1500毫秒轮询XML配置文件的变化,这不是一个可配置的设置。不过,你可以通过修改ConfigurationChangeFileWatcher源代码来改变轮询的频率。

    另外,Client端程序也可以通过调用ConfigurationManager.ClearSingletonCache方法来清除缓存。

    Code Snippet如下所示:

    private void btnClearCache_Click(object sender, System.EventArgs e)

    {

    // Removes all sections from the internal cache.

    ConfigurationManager.ClearSingletonSectionCache();

    txtConfigurationData.Text += "The cache of configuration data has been cleared." + Environment.NewLine;

    }

    作者:KKcat
        
    个人博客:http://jinzhao.me/
        
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Python元组、列表、字典
    测试通过Word直接发布博文
    Python环境搭建(windows)
    hdu 4003 Find Metal Mineral 树形DP
    poj 1986 Distance Queries LCA
    poj 1470 Closest Common Ancestors LCA
    poj 1330 Nearest Common Ancestors LCA
    hdu 3046 Pleasant sheep and big big wolf 最小割
    poj 3281 Dining 最大流
    zoj 2760 How Many Shortest Path 最大流
  • 原文地址:https://www.cnblogs.com/jinzhao/p/1440224.html
Copyright © 2011-2022 走看看