Exemple #1
0
        private async Task TestStorage()
        {
            _logger.LogTrace("TestStorage: start");

            var id = _dataCacheManager.IncrementValue("CustomerId", () =>
            {
                return(_dataStoreManager.Queryable <Customer>().OrderByDescending(c => c.Id).FirstOrDefault()?.Id ?? 0);
            });
            var customer = new Customer()
            {
                Id          = id,
                Name        = "Andy",
                CreatedDate = DateTime.Now
            };

            await _dataStoreManager.Insert <Customer>(customer);

            var lastcustomer = _dataStoreManager.Queryable <Customer>()
                               .Where(c => c.CreatedDate >= DateTime.Today).OrderByDescending(c => c.Id).First();

            _logger.LogInformation($"last one:id: {lastcustomer.Id},name:{lastcustomer.Name},create date:{lastcustomer.CreatedDate.LocalDateTime}");

            var firstcustomer = _dataStoreManager.Queryable <Customer>().First();

            await _dataStoreManager.Remove <Customer>((c) => c.Id == 5);

            _logger.LogInformation($"remove first one:id: {firstcustomer.Id},name:{firstcustomer.Name},create date:{firstcustomer.CreatedDate.LocalDateTime}");
        }
Exemple #2
0
        // GET api/values
        public IEnumerable <string> Get()
        {
            var val = _cacheManager.IncrementValue("WebApplication1_Test",
                                                   () =>
            {
                return(100);
            }
                                                   , expiredMinutes: 10);

            _logger.LogInformation($"ValuesController:Get:Values:{val}");

            return(new string[] { "value1", "value2", val.ToString() });
        }
Exemple #3
0
        public void Test()
        {
            var nval = _dataCacheManager.GetCachedData(new CacheItemArgs("testcore", 5), (cargs) =>
            {
                return((long)5);
            });
            var nval2 = _dataCacheManager.IncrementValue("testcore", () =>
            {
                return(10);
            });

            var strResult = $"IncrementValue-Low:{nval}->{nval2}";

            _logger.LogInformation(strResult);

            nval2 = _dataCacheManager.GetCachedDataLocalDistributed("testcoredistributed", (cargs) =>
            {
                return(10);
            }, 1);

            strResult = $"DataLocalDistributed:{nval}->{nval2}";

            _logger.LogInformation(strResult);
        }