Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [390]

By Root 5814 0
Services.

Figure 18-4. Architecture of AppFabric Caching Services.

The configuration script for the servers in the cache cluster contains the name of the cluster and general settings such as topology and data eviction policies. In addition, the configuration contains the list of servers and relative names and ports. Each service is configured to use two main ports: one to communicate with the client (cachePort) and one to communicate their availability to neighbors (clusterPort). Configuration information for the cluster is saved in one location, which can be an XML file on a shared network folder, a SQL Server database, or a custom store. Here’s an example excerpted from an XML file (clusterconfig.xml):

type="Microsoft.ApplicationServer.Caching.DataCacheSection,

Microsoft.ApplicationServer.Caching.Core, ..." />

arbitrationPort="22235"

clusterPort="22234"

hostId="879796007"

size="1007"

leadHost="true"

account="My-Laptop\DinoE"

cacheHostName="AppFabricCachingService"

name="My-Laptop"

cachePort="22233" />

Each server can have one or multiple caches of data. A data cache is simply a logical way of grouping data. Each enabled server has one default data cache (which is unnamed), but you are allowed to create your own. Data caches can be individually configured.

Each data cache is optionally made of regions. A region is a logical way of grouping data within a given data cache. Each region is defined programmatically on a given server and, unlike data caches, they do not span multiple servers. Finally, you have cached objects. A cached object is simply the data you store either directly in the data cache or in a region. Figure 18-5 provides an illustration.

Figure 18-5. Data caches and regions.

In Figure 18-5, you see that named and unnamed caches can span multiple servers, whereas optional regions are specific to just one server and are usually created via Windows PowerShell. As a developer, you are not interested in the location of a region; you only need to know whether it exists and what data it contains. In this way, you can provide more information to ACS and make it return data more quickly.

Note

To be precise, in ACS an unnamed cache is not really unnamed. It is just named in a default way and must still be explicitly created via the administration console of Windows PowerShell. The “unnamed” cache gets the name of “default.” The only difference between this and a regular named cache is that you can gain access to it using an additional shortcut method on the cache factory object—GetDefaultCache.

Client-Side Configuration of Caching Services


To use ACS in your ASP.NET pages, you need to configure the Web server environment first. This requires adding a section to the application’s web.config file. Here’s a snippet:

...

Obviously, you must first have available a bunch of AppFabric assemblies on the Web server so that you can safely declare the new dataCacheClient section in the configuration. For some reason, the ACS assemblies don’t show up in the Microsoft Visual Studio list of available assemblies and you have to catch them yourself in the folds of the %System%\AppFabric directory. You need to pick up two assemblies: Microsoft.ApplicationServer.Caching.Core and Microsoft.ApplicationServer.Caching.Client.

type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,

Microsoft.ApplicationServer.Caching.Core"

allowLocation="true"

allowDefinition="Everywhere" />

...

The dataCacheClient section specifies the desired deployment type, the list of hosts that provide cache data, and any optional settings regarding the local cache.

An ACS client can connect

Return Main Page Previous Page Next Page

®Online Book Reader