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

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>
            韩国免费一区| 午夜一区二区三区不卡视频| 久久久噜噜噜久久中文字免| 欧美一区二区三区视频在线观看| 国产精品亚洲а∨天堂免在线| 午夜精品久久久久影视| 亚洲尤物精选| 国模大胆一区二区三区| 六月婷婷一区| 欧美激情一区二区三区高清视频 | 久久五月天婷婷| 亚洲欧洲精品天堂一级| 亚洲精品美女在线| 国产精品久久久久久av下载红粉| 亚洲欧洲99久久| 久久精品国产亚洲aⅴ| 亚洲国产精品第一区二区| 日韩视频一区二区三区在线播放免费观看| 欧美午夜在线一二页| 久久久精品欧美丰满| 欧美成人激情视频免费观看| 亚洲影院免费观看| 久久久久久午夜| 亚洲网在线观看| 欧美在线一二三| 一区二区精品国产| 久久成人在线| 亚洲色在线视频| 久久免费视频网| 亚洲一区三区在线观看| 久久久久亚洲综合| 亚洲一区二区三区精品视频| 久久精品91久久香蕉加勒比| 一本久道久久综合狠狠爱| 欧美一区三区三区高中清蜜桃| 亚洲精品美女| 久久精品国产v日韩v亚洲| aaa亚洲精品一二三区| 久久国产精品99国产精| 在线一区亚洲| 开元免费观看欧美电视剧网站| 午夜精品福利一区二区蜜股av| 久久亚洲国产精品日日av夜夜| 亚洲欧美日韩中文视频| 欧美高清在线精品一区| 老鸭窝91久久精品色噜噜导演| 欧美日韩亚洲综合| 亚洲电影在线看| 精品69视频一区二区三区| 亚洲午夜久久久久久久久电影网| 亚洲精品乱码久久久久久黑人 | 久久青草久久| 欧美在线一二三四区| 欧美日韩一级视频| 亚洲国产精品久久| 亚洲国产福利在线| 久久精品人人做人人综合| 午夜性色一区二区三区免费视频| 欧美黑人多人双交| 欧美华人在线视频| 亚洲国产精品综合| 免费成人你懂的| 欧美国产成人精品| 亚洲国产高清aⅴ视频| 久久久激情视频| 久久午夜影视| 黄色成人精品网站| 久久久青草青青国产亚洲免观| 久久精品日产第一区二区三区| 国产精品一区二区在线观看| 中文av字幕一区| 午夜日韩福利| 国产精品私拍pans大尺度在线 | 久久中文精品| 18成人免费观看视频| 久久久久久9| 欧美激情二区三区| 亚洲精品资源| 国产精品大片wwwwww| 亚洲午夜一区二区三区| 性xx色xx综合久久久xx| 国产一区二区剧情av在线| 欧美在线视频全部完| 欧美成人一区在线| 日韩一级不卡| 国产精品久久国产精品99gif| 亚洲一区免费看| 久久久久免费视频| 亚洲欧洲另类国产综合| 欧美日韩国产精品自在自线| 亚洲一区免费看| 久久野战av| 一本不卡影院| 国产一区视频网站| 欧美成人免费播放| 亚洲女爱视频在线| 欧美高清hd18日本| 亚洲免费视频观看| 亚洲高清视频在线| 欧美视频在线观看一区| 久久成人精品无人区| 亚洲黄色有码视频| 欧美在线观看网站| 亚洲精品视频在线看| 国产精品一级久久久| 鲁大师影院一区二区三区| av不卡在线| 欧美成人免费一级人片100| 亚洲免费在线视频| 亚洲盗摄视频| 国产精品一二三| 欧美激情精品久久久久久| 午夜精品视频在线观看| 亚洲欧洲一区| 美国成人直播| 小黄鸭视频精品导航| 亚洲精品乱码久久久久久| 国产欧美一区二区精品仙草咪| 欧美国产亚洲精品久久久8v| 欧美在线观看视频| 亚洲天堂激情| 亚洲日本激情| 欧美不卡三区| 久久嫩草精品久久久精品一| 亚洲视频一区二区| 亚洲国产成人av好男人在线观看| 国产乱码精品一区二区三区不卡| 欧美精品亚洲二区| 免费亚洲网站| 老色鬼精品视频在线观看播放| 欧美一区二区三区在线免费观看| 9色精品在线| 亚洲精品一区二区三区在线观看| 欧美aⅴ一区二区三区视频| 久久精品论坛| 久久精品一二三区| 欧美亚洲一区| 欧美影院精品一区| 欧美亚洲视频| 香蕉成人伊视频在线观看| 亚洲一区二区精品视频| a91a精品视频在线观看| 99人久久精品视频最新地址| 亚洲毛片网站| 亚洲视频免费| 亚洲欧美激情在线视频| 亚洲欧美日产图| 午夜视频在线观看一区二区三区| 亚洲综合精品四区| 亚洲综合成人在线| 性欧美暴力猛交69hd| 欧美影院成人| 久久综合中文| 亚洲成色777777在线观看影院| 国产精品久久久久婷婷| 国产精品啊v在线| 国产精品自拍在线| 国产一区在线看| 亚洲国产婷婷香蕉久久久久久| 亚洲激情视频在线播放| 日韩天天综合| 午夜精品视频网站| 久久久五月天| 亚洲国产成人精品久久| 亚洲伦理中文字幕| 亚洲香蕉网站| 久久久久国色av免费观看性色| 久久久夜精品| 欧美日韩高清一区| 国产乱子伦一区二区三区国色天香 | 国产精品白丝jk黑袜喷水| 欧美激情按摩| 国产精品第一页第二页第三页| 国产美女诱惑一区二区| 一区二区在线观看视频| aa国产精品| 久久www成人_看片免费不卡 | 亚洲欧洲日本一区二区三区| 99视频在线观看一区三区| 亚洲欧美国产精品专区久久| 久久精品在线观看| 亚洲欧洲三级电影| 午夜免费久久久久| 欧美精品videossex性护士| 国产精品视频久久| 最新日韩欧美| 久久久久国产精品一区三寸| 亚洲黄色小视频| 欧美一级视频免费在线观看| 欧美成人中文字幕在线| 国产欧美精品va在线观看| 亚洲理伦电影| 久久一区亚洲| 亚洲免费伊人电影在线观看av| 久久婷婷丁香| 国产欧美一区二区精品忘忧草 | 国内精品久久久久伊人av| 夜久久久久久| 免费的成人av| 欧美一级久久久久久久大片|