青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Javen-Studio 咖啡小屋

http://javenstudio.org - C++ Java 分布式 搜索引擎
Naven's Research Laboratory - Thinking of Life, Imagination of Future

  C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
  24 隨筆 :: 57 文章 :: 170 評論 :: 4 Trackbacks
Enterprise Library 4.1 - October 2008
Design of the Caching Application Block

The Caching Application Block is designed to do the following:

  • It provides a set of APIs that are manageable in size.
  • It allows developers to incorporate the standard caching operations into their applications without having to learn the internal workings of the application block.
  • It uses the Enterprise Library configuration tools for easy configuration.
  • It performs efficiently.
  • It is thread safe. Code is considered to be thread safe when it can be called from multiple programming threads without unwanted interaction among those threads.
  • It ensures that the backing store remains intact if an exception occurs while it is being accessed.
  • It ensures that the states of the in-memory cache and the backing store remain synchronized.

This topic describes the design of the caching system, describing the highlights and specific design details. Other topics in this section include Design of the Expiration Process and Design of the Scavenging Process.

Figure 1 illustrates the interrelationships between the key classes in the Caching Application Block.

Dd203150.b4fde6b0-2e54-4dd0-a340-18e14ee2bf18(en-us,MSDN.10).png

Figure 1
Design of the Caching Application Block

When you initialize an instance of the CacheManager using the CacheFactory, it internally creates a CacheManagerFactory object, which in turn creates a Cache object. After the Cache object is created, all data in the backing store is loaded into an in-memory representation that is contained in the Cache object. Applications can then make requests to the CacheManager object to retrieve cached data, add data to the cache, and remove data from the cache.

When an application uses the GetData method to send a request to the CacheManager object to retrieve an item, the CacheManager object forwards the request to the Cache object. If the item is in the cache, it is returned from the in-memory representation in the cache to the application. If it is not in the cache, the request returns null. If the item is expired, the item also returns null.

When an application uses the Add method to send a request to the CacheManager object to add an item to the cache, the CacheManager object again forwards the request to the Cache object. If there is already an item with the same key, the Cache object first removes it before adding the new item to the in-memory store and the backing store. If the backing store is the default backing store, NullBackingStore, the data is written only to memory. If the number of cached items exceeds a predetermined limit when the item is added, the BackgroundScheduler object begins scavenging. When adding an item, the application can use an overload of the Add method to specify an array of expiration policies, the scavenging priority, and an object that implements the ICacheItemRefreshAction interface. This object can be used to refresh an expired item from the cache.

When adding an item that is not already in the in-memory hash table, the Cache object first creates a dummy cache item and adds it to the in-memory hash table. It then locks the cache item in the in-memory hash table, adds the item to backing store, and finally replaces the existing cache item in the in-memory hash table with the new cache item. (In the case where the item was already in the in-memory hash table, it replaces the dummy item.) If there is an exception while writing to the backing store, it removes the dummy item added to the in-memory hash table and does not continue. The Caching Application Block enforces a strong exception safety guarantee. This means that if an Add operation fails, the state of the cache rolls back to what it was before it tries to add the item. In other words, either an operation is completed successfully or the state of the cache remains unchanged. (This is also true for the Remove and Flush methods.)

The BackgroundScheduler object periodically monitors the lifetime of items in the cache. When an item expires, the BackgroundScheduler object first removes it and then, optionally, notifies the application that the item was removed. At this point, it is the responsibility of the application to refresh the cache.

The CacheManager class is the interface between the application and the rest of the Caching Application Block. All caching operations occur through this class. For developers who will be using the application block unmodified, the CacheManager object provides all the methods needed to add, retrieve, and remove items from the cache. Every method call made through the CacheManager object is thread safe.

To create an instance of a CacheManager object, the application uses the CacheFactory class, which in turn uses the CacheManagerFactory class. The CacheManagerFactory class creates all the internal classes needed to implement a CacheManager object.

Each name applies to only one cache. To create instances of multiple caches, use multiple names. Note that different caches, meaning caches with different names, cannot share the same backing store. There can be only one backing store for each CacheManager object.

The Cache object receives requests from the CacheManager object and implements all operations between the backing store and in-memory representation of the cached data. It contains a hash table that holds the in-memory representation of the data. (This is the form that users see.) An item of data is packaged as a CacheItem object. This object includes the data itself, together with other information such as the item's key, its priority, the RefreshAction object, and the expiration policy (or array of policies). It is stored in the hash table. The Cache object also uses a synchronized hash table to control access to the items in the cache, both from the application and from the BackgroundScheduler. The Cache object provides thread safety for the entire Caching Application Block.

The BackgroundScheduler object is responsible for expiring aging cache items and scavenging lower-priority cache items. A PollTimer object triggers the expiration cycle, and a numeric limit triggers the scavenging process. These are set in the configuration file.

The BackgroundScheduler object is an implementation of the active object pattern. This means that any other object (in this case, the PollTimer) talks to the BackgroundScheduler as if it existed on the thread of the calling object. After it is called, the BackgroundScheduler packages the request as a message and puts it in a queue collection object instead of immediately executing the requested behavior. (Remember that this all occurs in the caller's thread.) This queue is an example of the Producer-Consumer pattern. When the BackgroundScheduler is ready to process the message, an internal thread pulls the message from the queue. In effect, the BackgroundScheduler serializes all scavenging and expiration requests.

From its own thread, the BackgroundScheduler object sequentially removes messages from the queue and then executes the request. For the expiration process, it calls the Run method in the ExpirationTimeoutExpiredMsg class. For the scavenging process, it calls the Run method in the StartScavengingMsg class. The advantage of performing operations serially on a single thread is that it guarantees that the code will run in a single-threaded environment. This makes both the code and its effects simpler to understand.

The cache storage classes that are included with the Caching Application Block are the DataBackingStore class, the IsolatedStorageBackingStore class, and the NullBackingStore class. If you are interested in developing your own backing store, your class must either implement the IBackingStore interface or inherit from the abstract BaseBackingStore class, which implements the IBackingStore interface. This class contains implementations of common policies and utilities that can be used by all backing stores.

The DataBackingStore class is used when the backing store is the Data Access Application Block. Using the configuration tools, it is configured to use a named database instance. The IsolatedStorageBackingStore class stores cache items in domain-specific isolated storage. Using the Configuration Console, it is configured to use a named isolated storage. The Caching Application Block communicates with all backing stores through the IBackingStore interface.

The DataBackingStore and IsolatedStorageBackingStore classes can encrypt cache item data before it is persisted to storage. The encryption of cache item data is enabled through configuration. Using the configuration tools, cache storage can be configured to use a named symmetric encryption algorithm provider. The named provider is also used when reading data from the cache storage to decrypt the data before populating the cache with the item data.


posted on 2008-12-26 17:16 Javen-Studio 閱讀(853) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲午夜精品17c| 久久一区二区三区国产精品| 亚洲第一福利社区| 久久久欧美精品| 亚洲国产精品t66y| 欧美国产日韩精品| 欧美日韩岛国| 欧美亚洲视频在线看网址| 亚洲男女自偷自拍| 一区在线播放| 91久久久一线二线三线品牌| 欧美日韩精品中文字幕| 午夜激情综合网| 久久久国产一区二区| 亚洲国产另类 国产精品国产免费| 欧美国产高清| 国产精品久久一区主播| 久久国产精品72免费观看| 久久青青草原一区二区| 一本大道久久a久久精品综合 | 国产一区二区成人久久免费影院| 久久久久久综合网天天| 欧美成年人视频网站欧美| 亚洲免费网站| 久久综合久久综合久久综合| 一道本一区二区| 欧美一区二区三区另类| 99这里只有久久精品视频| 亚洲女爱视频在线| 亚洲日本成人网| 午夜日韩视频| 亚洲小说区图片区| 久久综合狠狠| 欧美一区二区三区四区在线 | 久久免费国产精品| 亚洲少妇诱惑| 久热精品视频在线| 羞羞色国产精品| 欧美久久久久久| 美女精品视频一区| 国产精品视频你懂的| 亚洲成人在线网站| 狠狠色狠狠色综合日日五| 在线亚洲一区二区| 亚洲日韩第九十九页| 久久精品国产久精国产思思| 亚洲一区二区成人| 欧美激情1区2区3区| 久久网站免费| 国产欧美日韩在线观看| 一区二区三区国产精华| 亚洲欧洲久久| 久久久五月天| 久久美女艺术照精彩视频福利播放| 欧美日韩成人在线视频| 亚洲高清在线观看一区| 曰韩精品一区二区| 久久精品女人| 久久婷婷麻豆| 狠狠爱www人成狠狠爱综合网| 亚洲午夜精品一区二区| 一区二区国产日产| 欧美国产日韩精品| 亚洲人体1000| 夜夜嗨av色综合久久久综合网| 欧美 日韩 国产一区二区在线视频| 久久手机免费观看| 很黄很黄激情成人| 久久精品欧美日韩| 牛人盗摄一区二区三区视频| 极品尤物av久久免费看| 久久久久这里只有精品| 久热精品视频| 亚洲高清在线| 欧美极品在线观看| 99re6这里只有精品| 亚洲一区国产| 国产私拍一区| 久久久久国产精品一区| 欧美国产欧美综合| 亚洲精品麻豆| 国产精品成人播放| 午夜在线视频观看日韩17c| 久久精品视频在线观看| 在线免费观看日本欧美| 欧美高清在线一区| 中文久久乱码一区二区| 久久精品国产亚洲精品| 亚洲第一福利社区| 欧美精品一区二区三| 中国亚洲黄色| 麻豆久久精品| 99在线热播精品免费| 国产精品免费福利| 久久夜色撩人精品| 一区二区激情| 久久久久久久999精品视频| 亚洲国产精品成人综合| 欧美日韩dvd在线观看| 亚洲男人的天堂在线| 欧美成人情趣视频| 午夜精品成人在线视频| 狠狠色丁香久久婷婷综合_中| 欧美激情视频给我| 欧美影院午夜播放| 亚洲精品日韩欧美| 噜噜噜91成人网| 一区二区三区www| 一区二区自拍| 国产精品入口夜色视频大尺度 | 亚洲免费观看在线视频| 久久人人97超碰国产公开结果 | 国产精品少妇自拍| 欧美不卡在线| 欧美制服丝袜第一页| 亚洲免费激情| 欧美黄色影院| 久久综合久久综合久久综合| 亚洲少妇一区| 亚洲精品综合| 亚洲国产99| 国产一区二区三区高清在线观看| 欧美日本三区| 欧美电影免费| 久久野战av| 久久久国产一区二区| 亚洲亚洲精品三区日韩精品在线视频| 欧美激情中文字幕一区二区| 久久久久久一区二区| 午夜精品理论片| 亚洲性视频h| 一本色道久久综合亚洲精品按摩| 黄色精品一区二区| 国产专区综合网| 国产区亚洲区欧美区| 国产精品色网| 国产精品社区| 国产欧美精品一区| 国产欧美日韩激情| 国产精品视频免费观看www| 欧美三区美女| 国产精品xxx在线观看www| 欧美人与禽猛交乱配| 欧美另类一区| 欧美深夜影院| 国产精品久久99| 国产精品视频久久| 国产欧美一区二区三区在线看蜜臀 | 亚洲一区二区三区四区视频| 一道本一区二区| 亚洲香蕉伊综合在人在线视看| 亚洲精品视频在线观看免费| 亚洲精选在线观看| 99精品久久| 亚洲综合色噜噜狠狠| 翔田千里一区二区| 久久精品99国产精品| 久久夜色精品国产欧美乱| 蜜臀久久久99精品久久久久久| 美女久久一区| 欧美视频在线观看 亚洲欧| 国产精品乱码人人做人人爱| 国产精品欧美激情| 国产在线精品一区二区中文| 影音先锋日韩资源| 在线午夜精品自拍| 午夜在线一区二区| 麻豆精品视频在线观看| 亚洲国产精品悠悠久久琪琪| 一本色道久久加勒比88综合| 午夜精品999| 欧美成人69| 国产欧美日韩不卡免费| 在线观看视频一区二区| 中国女人久久久| 久久久之久亚州精品露出| 亚洲第一黄网| 亚洲一区二区三区四区五区午夜| 欧美综合国产| 欧美日韩天天操| 加勒比av一区二区| 亚洲深夜激情| 久久综合一区| 亚洲性视频网址| 欧美成人精品影院| 国产欧美三级| 亚洲视频你懂的| 欧美成人精品不卡视频在线观看| 一本一本久久| 久久伊人亚洲| 国产精品尤物| 在线一区二区日韩| 欧美成人精品影院| 亚洲欧美日韩一区二区| 欧美欧美全黄| 亚洲国产精品99久久久久久久久| 午夜精品久久久99热福利| 亚洲国产精品热久久| 久久久91精品国产一区二区三区 | 亚洲欧美一区二区原创|