Configure Azure In-Role Cache
Updated: August 25, 2015
|Microsoft recommends all new developments use Azure Redis Cache. For current documentation and guidance on choosing an Azure Cache offering, see Which Azure Cache offering is right for me?|
This topic describes how to configure role-based In-Role Cache. Configuration includes two distinct tasks.
Configure a Azure role to host In-Role Cache. This step includes creating named caches and configuring the settings of those named caches. This provides the caching capabilities to any of the roles in the same cloud service deployment.
Configure any roles that require caching. This includes adding assembly references and settings in the configuration file that point to the role that hosts In-Role Cache.
For more details on caching configuration, see Configuration Model in Azure In-Role Cache.
To use role-based In-Role Cache, you must first configure a role to host caching. This could be a new Cache Worker Role that you add to your cloud service, referred to as a dedicated topology. Dedicated role caching is supported on worker roles. For details on configuring a dedicated topology in Visual Studio, see Hosting Azure In-Role Cache on Dedicated Roles.
Alternatively, you can choose to use an existing role that has available physical resources to share with In-Role Cache. This is referred to as a co-located topology. Co-located role caching is supported on web roles and worker roles. For details on configuring a co-located topology in Visual Studio, see Hosting Azure In-Role Cache on Existing Roles.
The final step is to create any additional named caches and to configure each cache. For more information, see How To: Configure Azure Caching.
|Configuring the role in Visual Studio results in configuration changes to the underlying ServiceConfiguration.cscfg and ServiceDefinition.csdef files. For more information, see Configuration Model in Azure In-Role Cache. For manual configuration of the ServiceConfiguration.cscfg file, see In-Role Cache Role Configuration Settings (ServiceConfiguration.cscfg).|
Any other code in the cloud service can access the named caches as cache clients. The configuration steps here typically include:
Reference the appropriate caching assemblies.
Add caching configuration settings to application or web.config configuration files.
For examples of the client configuration file settings, see Configuration Model in Azure In-Role Cache.
|These steps are simplified by the use of a NuGet package to configure a project to become a cache client. For more information, see How to: Prepare Visual Studio to Use Azure In-Role Cache. For manual configuration of the web.config and application.config files, see In-Role Cache Client Configuration Settings (Web.config).|