Windows Azure Caching: Difference between revisions

Content deleted Content added
mNo edit summary
Removing link(s) to "AppFabric Caching": Removing links to deleted page AppFabric Caching.
 
(5 intermediate revisions by 5 users not shown)
Line 1:
'''Windows Azure Caching''' was an in-memory, [[Distributed cache|distributed caching]] feature designed for [[WindowsMicrosoft Azure]] applications.<ref name=CachingMain>{{cite web|title=Caching in Windows Azure|url=http://msdn.microsoft.com/en-us/library/gg278356.aspx|work=MSDN Library|publisher=Microsoft|accessdate=12 February 2013}}</ref> 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]].<ref>{{cite web|last1=Rastogi|first1=Pranav|title=Azure Managed Cache and In-Role Cache services to be retired on 11/30/2016|url=https://azure.microsoft.com/en-us/blog/azure-managed-cache-and-in-role-cache-services-to-be-retired-on-11-30-2016/|website=Microsoft Azure Blog|accessdate=22 March 2017|date=3 December 2015}}</ref>
 
==Architecture==
Windows Azure Caching allows a cloud service to host Caching on a Windows Azure role.<ref name="CachingMain">{{cite web |title=Caching in Windows Azure |url=http://msdn.microsoft.com/en-us/library/gg278356.aspx |accessdate=12 February 2013 |work=MSDN Library |publisher=Microsoft}}</ref> The cache is distributed across all running instances of that role. Therefore, the amount of available memory in the cache is determined by the number of running instances of the role that hosts Caching and the amount of physical memory reserved for Caching on each instance.<ref name=CachingCapacityPlanning>{{cite web|title=Capacity Planning Considerations for Windows Azure Caching|url=http://msdn.microsoft.com/en-us/library/hh914129.aspx|work=MSDN Library|publisher=Microsoft|accessdate=13 February 2013}}</ref>
 
There are two deployment topologies for Caching:
Line 47:
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=CSharp"csharp">
DataCachevar Cachecache = new DataCache("NamedCache2", "customClient");
</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=CSharp"csharp">
dataType GetUserData(string useriduserId)
{
dataType data = null;
 
// Attempt to retrieve the user data from the cache:
object dataObject = Cache.Get(useriduserId);
 
if (dataObject != null)
Line 66:
{
// If it doesn't exist in the cache, retrieve it from the database:
data = GetUserDataFromDatabase("SELECT * FROM users WHERE useriduserId = @useriduserId", useriduserId);
 
// Put the returned data in the cache for future requests:
Cache.Add(useriduserId, data);
}
 
Line 78:
The following method shows how to update data that is already in the cache.
 
<syntaxhighlight lang=CSharp"csharp">
void UpdateUserData(string useriduserId, dataType data)
{
// Update the user information in the database:
result = UpdateUserDataInDatabase(useriduserId, data);
if (result)
{
// If successfully updated, update the cache:
Cache.Put(useriduserId, data);
}
}
Line 94:
The following call removes the item from the cache.
 
<syntaxhighlight lang=CSharp"csharp">
Cache.Remove(useriduserId);
</syntaxhighlight>
 
Line 102:
 
==History==
Windows Azure Caching has its roots in an on-premises technology, [[AppFabric]]. It was originally released as one of several Windows Azure AppFabric services, but the AppFabric designation in Windows Azure has since been abandoned. Many of the assembly names, namespaces, and APIs are identical between Windows Azure Caching and AppFabric Caching.<ref name=CachingOnPremisesAndCloud>{{cite web|title=Differences Between Caching On-Premises and in the Cloud|url=http://msdn.microsoft.com/en-us/library/gg185678.aspx|work=MSDN Library|publisher=Microsoft|accessdate=13 February 2013}}</ref> The first release of Caching for Windows Azure in April 2011 provided caching as a managed service in Windows Azure.<ref name=Caching2011Release>{{cite web|title=Introducing the Windows Azure Caching Service|url=http://msdn.microsoft.com/en-us/magazine/gg983488.aspx|work=MSDN Magazine|publisher=Microsoft|accessdate=13 February 2013}}</ref> This offering is now called Shared Caching.
 
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> This is now called Windows Azure Caching.
Line 113:
! Caching Technology !! Target !! Installed By !! Description
|-
| [[AppFabric Caching Service|AppFabric Caching]] || [[On-premises software|On-Premises]] || [[AppFabric]] || Distributed on-premises cache that uses servers that the user provisions and manages.
|-
| [[Windows Azure Caching#Architecture|Windows Azure Caching]] || [[Cloud computing|Cloud]] || [http://www.windowsazure.com/en-us/develop/net/#/ Windows Azure SDK] || Caching is distributed across the instances of a single role in a Windows Azure cloud service deployment.