/// <summary>
 /// 获取缓存对象
 /// </summary>
 /// <param name="regionName">缓存区域名称</param>
 /// <returns></returns>
 public ICache GetCache(string regionName)
 {
     ICache cache;
     if (Caches.TryGetValue(regionName, out cache))
     {
         return cache;
     }
     cache = new RuntimeMemoryCache(regionName);
     Caches[regionName] = cache;
     return cache;
 }
Example #2
0
        public void Get_Key_CacheGetCalled()
        {
            // Arrange
            var mockObjectCache = new Mock <ObjectCache>();
            var cache           = new RuntimeMemoryCache(mockObjectCache.Object);

            // Act
            cache.Get("abc123");

            // Assert
            mockObjectCache.Verify(c => c.Get("abc123", It.IsAny <string>()));
        }
Example #3
0
        static async Task <string> Thing()
        {
            var http     = new RestHttpClient(new System.Net.Http.HttpClient());
            var memCache = new RuntimeMemoryCache(System.Runtime.Caching.MemoryCache.Default);
            var clientCredentialsAuthApi = new ClientCredentialsAuthorizationApi(http, System.Configuration.ConfigurationManager.AppSettings, memCache);
            var api = new PlaylistsApi(http, clientCredentialsAuthApi);

            var playlists = await api.GetPlaylists("davemateer");

            Trace.TraceInformation(playlists.ToString());
            return("xx");
        }
Example #4
0
        public void Add_Value_CacheAddCalled()
        {
            // Arrange
            var expiry = DateTime.Now.AddHours(1);

            var mockObjectCache = new Mock <ObjectCache>();
            var cache           = new RuntimeMemoryCache(mockObjectCache.Object);

            // Act
            cache.Add("abc123", "def345", expiry);

            // Assert
            mockObjectCache.Verify(c => c.Add("abc123", "def345", expiry, It.IsAny <string>()));
        }