Content deleted Content added
Removing link(s) to "AppFabric Caching": Removing links to deleted page AppFabric Caching. |
|||
(18 intermediate revisions by 13 users not shown) | |||
Line 1:
an in-memory, distributed caching feature designed for Microsoft Azure applications. Caching was available as a part of the Windows Azure SDK. The Azure Managed Cache and In-Role Cache services were retired, and Microsoft recommended migration to Azure Redis Cache.
==Architecture==
Windows Azure Caching allows a cloud service to host Caching on a Windows Azure role.<ref name="CachingMain
There are two deployment topologies for Caching:
Line 15 ⟶ 13:
The following diagram shows Caching in a dedicated topology. The cloud service shown has three roles: Web1, Worker1, and Cache1. There are two running instances of each role. In this example, the cache is distributed across all instances of the dedicated Cache1 role.
[[File:Windows Azure Caching (Dedicated).jpg
A dedicated topology has the advantage of scaling the caching tier independently of any other role in the cloud service.<ref name=CachingCacheCluster>{{cite web|title=About Windows Azure Caching, Cache Cluster|url=http://msdn.microsoft.com/en-us/library/hh914161.aspx#Concept_CacheClusters|work=MSDN Library|publisher=Microsoft|accessdate=13 February 2013}}</ref>
===Co-located topology===
In a co-located topology, you use a percentage of available memory on existing web or worker roles for Caching.<ref name=CachingColocated/>
The following diagram shows Caching in a co-located topology. The cloud service has two roles: Web1 and Worker1. There are two running instances of each role. In this example, the cache is distributed across all instances of the Web1 role. Because this role also hosts the web front-end for the cloud service, the cache is configured to use only a percentage of the physical memory on each instance of the Web1 role.
[[File:Windows Azure Caching (Co-located).jpg
A co-located cache is a cost-effective way to make use of existing memory on a role within a cloud service.<ref name=CachingColocated/>
==Examples==
Line 32 ⟶ 30:
===Configuration example===
In [[
Other roles must be configured to use Caching.<ref name=CacheClientConfig>{{cite web|title=Getting Started with Development for Windows Azure Caching, Configure the Clients|url=http://msdn.microsoft.com/en-us/library/hh914150.aspx|work=MSDN Library|publisher=Microsoft|accessdate=13 February 2013}}</ref>
<syntaxhighlight lang=XML>
Line 45 ⟶ 43:
===Code examples===
''Note that the code samples in this section are shown in [[
When hosting Caching on roles, the '''DataCache''' class constructor can be used to specify both the named cache and the '''dataCacheClient''' section for the cache client settings. The following code shows how to create a named cache, ''NamedCache2'', using the settings from a '''dataCacheClient''' section named ''customClient''.
<syntaxhighlight lang=
</syntaxhighlight>
The following method shows how to use the ''Cache'' object to retrieve data from the cache. In this example, a user identifier (''userid'') is the key for the associated user information object. The code first attempts to get this user information from the cache using the ''userid'' key. If that does not succeed, the code retrieves the information with a database query and then stores the returned user data in the cache. The next time the same code is run, the user information will be returned from the cache rather than the database. This assumes that the cached data has not been expired or evicted.
<syntaxhighlight lang=
dataType
{
dataType data =
if (!data) {▼
// Attempt to retrieve the user data from the cache:
object dataObject = Cache.Get(userId);
data = db_select("SELECT * FROM users WHERE userid = ?", userid);▼
if (dataObject != null)
Cache.Add(userid, data);▼
data = (dataType)dataObject;
else
{
// If it doesn't exist in the cache, retrieve it from the database:
▲ data =
// Put the returned data in the cache for future requests:
}
return data;
}
Line 71 ⟶ 78:
The following method shows how to update data that is already in the cache.
<syntaxhighlight lang=
void
{
// Update the user information in the database:
result = UpdateUserDataInDatabase(userId, data);
{
// If successfully updated, update the cache:
Cache.Put(
}
}
Line 86 ⟶ 94:
The following call removes the item from the cache.
<syntaxhighlight lang=
Cache.Remove(
</syntaxhighlight>
==Shared Caching==
Windows Azure Shared Caching provides caching as a managed service.<ref name=SharedCaching>{{cite web|title=About Windows Azure Shared Caching|url=http://msdn.microsoft.com/en-us/library/hh697519.aspx|work=MSDN Library|publisher=Microsoft|accessdate=13 February 2013}}</ref>
==History==
Windows Azure Caching has its roots in an on-premises technology,
In October 2012, support was added for hosting Caching on roles within a cloud service deployment.<ref name=CachingRelNotes>{{cite web|title=Windows Azure Caching Release Notes (October 2012)|url=http://msdn.microsoft.com/library/jj651667.aspx|work=MSDN Library|publisher=Microsoft|accessdate=13 February 2013}}</ref>
==Related caching technologies==
Windows Azure Caching is related to other Microsoft caching technologies. These technologies share similar features, such as the assembly name, namespace, and types.<ref name=CachingOnPremisesAndCloud/>
{| class="wikitable"
Line 105 ⟶ 113:
! Caching Technology !! Target !! Installed By !! Description
|-
|
|-
| [[Windows Azure Caching#Architecture|Windows Azure Caching]] || [[
|-
| [[Windows Azure Caching#Shared Caching|Windows Azure Shared Caching]] || [[
|}
Line 122 ⟶ 130:
* [http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.applicationserver.caching Windows Azure Caching Class Library Reference]
{{Microsoft Azure Services Platform}}
[[Category:Microsoft cloud services]]
[[Category:Database caching]]
[[Category:Cache (computing)]]
|