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

Javen-Studio 咖啡小屋

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

  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
  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 閱讀(846) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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>
            欧美成人69| 久久亚洲私人国产精品va| 久久精品夜色噜噜亚洲a∨| 99这里只有久久精品视频| 亚洲日本中文字幕| 亚洲人被黑人高潮完整版| 亚洲国产婷婷香蕉久久久久久| 1024成人网色www| 亚洲人午夜精品| 一区二区三区日韩| 亚洲欧美日韩中文视频| 久久er99精品| 欧美黄色日本| 在线视频日韩精品| 欧美一区二区观看视频| 美女图片一区二区| 欧美日韩一区二区三区在线观看免| 欧美午夜视频网站| 狠狠久久五月精品中文字幕| 亚洲片国产一区一级在线观看| 亚洲视频你懂的| 久久综合伊人| 亚洲视频在线观看免费| 久久久99国产精品免费| 欧美日韩一区二| 黄色欧美成人| 亚洲欧美国产日韩天堂区| 蜜桃av一区二区三区| 日韩亚洲精品电影| 久久久综合视频| 国产精品伦一区| 亚洲精品乱码久久久久| 久久精品视频亚洲| 一本综合精品| 免费观看一级特黄欧美大片| 国产日韩欧美高清| 亚洲调教视频在线观看| 欧美激情视频一区二区三区免费| 亚洲欧美卡通另类91av| 欧美精品一级| 亚洲国产一二三| 久久综合九色综合久99| 亚洲伊人观看| 欧美日韩亚洲国产精品| 亚洲盗摄视频| 久久免费视频在线| 一区二区日韩精品| 欧美日韩不卡一区| 亚洲激情六月丁香| 牛牛国产精品| 久久精品午夜| 亚洲天天影视| 亚洲午夜三级在线| 欧美美女日韩| 日韩视频在线免费| 噜噜噜91成人网| 久久久久www| 精品动漫av| 免费视频一区二区三区在线观看| 欧美亚洲日本国产| 国产字幕视频一区二区| 午夜精品一区二区三区在线| 99国产精品一区| 欧美日韩一区在线| 亚洲一二三四区| 亚洲私拍自拍| 国产情人综合久久777777| 欧美专区亚洲专区| 性18欧美另类| 国产在线观看精品一区二区三区 | 欧美承认网站| 欧美mv日韩mv国产网站| 亚洲经典在线| 亚洲靠逼com| 国产精品久久久一本精品| 午夜激情一区| 久久爱www.| 91久久久久久久久| 99人久久精品视频最新地址| 国产精品女人网站| 久久精品在线观看| 久久青草久久| 一区二区三区色| 一区二区三区国产盗摄| 国产一级精品aaaaa看| 蜜桃精品久久久久久久免费影院| 欧美成人一品| 午夜精品久久久久久久99水蜜桃| 午夜视频精品| 欧美aⅴ99久久黑人专区| 亚洲精品日韩激情在线电影 | 欧美韩日亚洲| 亚洲小说欧美另类社区| 亚洲欧美怡红院| 在线免费观看欧美| 在线亚洲观看| 亚洲激情影院| 亚洲欧美在线x视频| 亚洲精品1234| 欧美一区二区三区久久精品茉莉花 | 欧美精品系列| 久久久www成人免费毛片麻豆| 久久亚洲色图| 久久爱另类一区二区小说| 欧美精品18+| 亚洲国产精品综合| 亚洲第一综合天堂另类专| 久久婷婷国产综合精品青草 | 国产精品国产福利国产秒拍| 久久久综合网站| 欧美日韩一级大片网址| 欧美电影电视剧在线观看| 国产精品日韩欧美一区二区| 亚洲国产日韩欧美在线99| 国产又爽又黄的激情精品视频| 99re成人精品视频| 亚洲啪啪91| 狼人社综合社区| 久久久精品性| 国产日韩综合一区二区性色av| 亚洲经典一区| 亚洲激情av| 久久久久久综合网天天| 午夜精品免费视频| 欧美日韩亚洲网| 亚洲欧洲三级| 亚洲精品美女在线观看| 久久免费高清| 玖玖国产精品视频| 韩国一区二区在线观看| 亚洲欧美日韩电影| 欧美一区二区三区播放老司机| 欧美日韩国产高清视频| 亚洲人成网站影音先锋播放| 亚洲精品国精品久久99热一| 免费不卡在线视频| 亚洲大片av| 亚洲精选在线| 欧美电影在线播放| 亚洲精品韩国| 亚洲深夜激情| 国产精品第2页| 亚洲性av在线| 久久久不卡网国产精品一区| 国产欧美日韩亚洲精品| 午夜日韩福利| 噜噜噜在线观看免费视频日韩| 激情一区二区三区| 免费成年人欧美视频| 亚洲欧洲免费视频| 亚洲欧美日韩国产一区二区三区 | 久久久久久999| 欧美大片一区| 宅男在线国产精品| 国产精品午夜在线观看| 久久国产日韩欧美| 欧美高清视频| 亚洲午夜久久久久久久久电影院| 欧美性片在线观看| 欧美一二三区在线观看| 欧美黑人在线播放| 亚洲一区二区三区三| 国产亚洲精品久| 欧美成黄导航| 亚洲一区二区三区色| 久久综合电影一区| 亚洲最新视频在线播放| 国产欧美日韩视频在线观看 | 久久久久久网| 国产精品色婷婷| 久久激情视频免费观看| 亚洲国产精品一区二区久| 一区二区三区欧美亚洲| 国产在线精品二区| 欧美另类久久久品| 欧美专区在线观看| 亚洲区免费影片| 久久久久久91香蕉国产| 99热在这里有精品免费| 国产日韩精品一区| 欧美日韩国产999| 久久久噜噜噜久久久| 亚洲免费av观看| 美女91精品| 午夜欧美大尺度福利影院在线看| 激情久久一区| 国产精品久久综合| 欧美激情a∨在线视频播放| 亚洲欧美日韩中文播放| 亚洲片国产一区一级在线观看| 久久久精品国产一区二区三区| 亚洲一区二区视频| 亚洲免费观看在线观看| 精品福利电影| 国产日韩欧美综合在线| 国产精品久久久999| 欧美区国产区| 欧美激情成人在线| 久久亚洲欧美国产精品乐播| 先锋影音国产精品|