Skip to content

Instantly share code, notes, and snippets.

@lawrencegripper
Last active October 11, 2015 09:58
Show Gist options
  • Save lawrencegripper/2beafe11eef1e024e493 to your computer and use it in GitHub Desktop.
Save lawrencegripper/2beafe11eef1e024e493 to your computer and use it in GitHub Desktop.
Azure Cache from Cloud Config
/// <summary>
        /// Wrapper for the cache factory to create a DataCache from Authentication token and discovery url
        /// </summary>
        /// <param name="token"></param>
        /// <param name="discoveryurl"></param>
        /// <returns></returns>
        private DataCache CacheFactoryWrapper(string token, string discoveryurl)
        {
            DataCacheFactoryConfiguration config = new DataCacheFactoryConfiguration();
            config.AutoDiscoverProperty = new DataCacheAutoDiscoverProperty(true, discoveryurl);
            if (!String.IsNullOrEmpty(token))
            { 
                config.SecurityProperties = new DataCacheSecurity(token);
            }
            DataCacheFactory cacheFactory = new DataCacheFactory(config);
            DataCache cache = cacheFactory.GetDefaultCache();
            return cache;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment