Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public async Task <ActionResult <string> > Get(string key)
        {
            var value = await _cacheService.GetCacheValueAsync(key);

            if (string.IsNullOrEmpty(value))
            {
                return(NotFound());
            }

            return(Ok(value));
        }