public async Task Post(IFormCollection fc) { var key = fc["key"]; var value = fc["value"]; await _cacheService.SetCacheValueAsync(key, value); }
public void TestRedisCache() { IConnectionMultiplexer connectionMultiplexer = ConnectionMultiplexer.Connect(configuration: "localhost:6379"); ICacheService cacheService = new RedisCacheService(connectionMultiplexer); string keyItemCache = "UnitTest"; var result = cacheService.GetCacheValueAsync(keyItemCache).GetAwaiter().GetResult(); Assert.IsNull(result); cacheService.SetCacheValueAsync(keyItemCache, "Some text here.").GetAwaiter(); result = cacheService.GetCacheValueAsync(keyItemCache).GetAwaiter().GetResult(); Assert.IsNotNull(result); }