Exemplo n.º 1
0
        /// <summary>
        /// First return cached result, then refresh this result with live value
        /// </summary>
        private void CacheRefreshAction()
        {
            CacheRefreshResult = string.Empty;

            //Fire task
            //Will show loader in the UI
            CacheRefreshDataLoader.LoadCacheThenRefreshAsync(() => JsonCache.GetFromCache <string>("key6"), () => JsonCache.GetAsync("key6", () => LongRunningOperation(DateTime.Now.Second.ToString()), expireDate: DateTime.Now.AddDays(1), forceRefresh: true), x =>
            {
                CacheRefreshResult = x;
            });
        }
Exemplo n.º 2
0
        public async Task SetExpireDateInValidTest()
        {
            //Clear the cache
            await JsonCache.ClearAll();

            await JsonCache.Set("test", "result set", DateTime.Now.AddDays(-1));

            var emptyResult = await JsonCache.GetFromCache <string>("test");

            Assert.AreEqual(null, emptyResult);
        }
Exemplo n.º 3
0
        public async Task GetCacheKeyTest()
        {
            //Clear the cache
            await JsonCache.ClearAll();

            var emptyResult = await JsonCache.GetFromCache <string>("test");

            Assert.AreEqual(null, emptyResult);

            await JsonCache.Set("test", "result set");

            var result = await JsonCache.GetFromCache <string>("test");

            Assert.AreEqual("result set", result);
        }