Beispiel #1
0
        public WebCacheInstance()
        {
            //initialize
            ProdDefs = new List <ProdDef>();
            Quotes   = new List <Quote>();

            mapper = MapperConfig.GetAutoMapperConfiguration().CreateMapper();

            _redisClientsManager = YJYGlobal.PooledRedisClientsManager;

            //get value from Redis
            using (var redisClient = _redisClientsManager.GetClient())
            {
                try
                {
                    ProdDefs = redisClient.As <ProdDef>().GetAll();
                    Quotes   = redisClient.As <Quote>().GetAll();
                }
                catch (Exception e)
                {
                    YJYGlobal.LogExceptionAsInfo(e);
                }
            }

            //set timer
            _timerProdDef = new Timer(UpdateProdDefs, null, _updateIntervalProdDef, TimeSpan.FromMilliseconds(-1));
            _timerQuote   = new Timer(UpdateQuotes, null, _updateIntervalQuote, TimeSpan.FromMilliseconds(-1));
        }