SPRZEDAŻ: 1-800-867-1389
EN
Ta zawartość nie jest dostępna w wymaganym języku. Wersja w języku angielskim znajduje się tutaj.

Local Cache for Azure Managed Cache Service

Updated: July 16, 2010

noteNote
For guidance on choosing the right Azure Cache offering for your application, see Which Azure Cache offering is right for me?.

Local cache is a feature of Microsoft Azure Cache that improves performance by reducing network requests to the cache service. caching stores objects in serialized form in a distributed in-memory cache. When an application requests an object from the cache, the serialized object is sent to the requesting application over the network. The application then deserializes the object for its use. To speed up the process of retrieving an object, enable local cache.

Local Cache Overview

When local cache is enabled, the cache client stores a reference to the object locally. This local reference keeps the object active in the memory of the client application. When the application requests the object, the cache client checks whether the object resides in the local cache. If so, the reference to the object is returned immediately without contacting the cache service. If it does not exist, the object is retrieved from the cache service. The cache client then deserializes the object and stores the reference to this newly retrieved object in the local cache. The client application uses this same object.

The lifetime of an object in the local cache depends on the maximum number of objects in the local cache and the invalidation policy. There are two types of invalidation for local cache: time-out-based invalidation and notification-based invalidation. For more information, see Expiration and Eviction for Azure Managed Cache Service.

Configuration Settings

Local cache can be enabled and configured using the web.config or application configuration file. You can add a localCache element to the dataCacheClient section. The following table lists the attributes of the localCache element.

 

Attribute Description

isEnabled

Set to true or false to enable or disable local cache.

sync

Determines how the local cache is invalidated. Possible values are TimeoutBased and NotificationBased.

objectCount

The maximum number of objects to store in the local cache. The default is 10000.

ttlValue

The number of seconds that objects stay in the local cache. The default is 300 seconds.

A sync value of TimeoutBased keeps objects cached locally until the ttlValue limit is reached. A value of NotificationBased uses notifications in addition to the timeout-based mechanism. To use notifications for invalidation, notifications must first be enabled for the cache by following the steps in Enabling Cache Notifications. The polling interval for notifications checks to see if items in the local cache have changed. An effective polling interval for notifications must be shorter than the ttlValue setting to be effective. An addition element, clientNotification, can be used to configure the poll interval for notifications by setting the pollInterval attribute to the number of second. The default is 300 seconds.

noteNote
Notifications are available in the Standard and Premium cache offerings, and are not available in the Basic cache offering. For more information, see Cache Offerings for Azure Managed Cache Service.

Examples

The following example shows a dataCacheClient section that uses local cache with timeout-based local expiration of five minutes (300 seconds).

<dataCacheClient name="default">
  <!-- Other configuration settings for cache omitted -->
  <localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />
</dataCacheClient>

The following example shows the previous dataCacheClient section changed to use notifications to provide additional synchronization by polling every one minute (60 seconds).

<dataCacheClient name="default">
  <!-- Other configuration settings for cache omitted -->
  <localCache isEnabled="true" sync="NotificationBased" objectCount="100000" ttlValue="300" />
  <clientNotification pollInterval="60" />
</dataCacheClient>

To download a sample that uses local cache, see the Cache API and Performance Sample.

See Also

Czy oceniasz te materiały jako pomocne?
(Pozostało znaków: 1500)
Dziękujemy za opinię.

Zawartość społeczności

Dodaj
Pokaż:
© 2014 Microsoft