示例#1
0
 public void Put <T>(string key, T item)
 {
     lock (_padlock)
     {
         SqlCache.Put(key, item.ToByteArray());
         InMemoryCache.Put(key, item);
     }
 }
示例#2
0
        public WheelEntity Get(WheelFilter filter)
        {
            var wheel = _inMemoryCache.Get(filter.ManufacturerName);

            if (wheel == null)
            {
                wheel = _repository.Get(filter);

                _inMemoryCache.Put(filter.ManufacturerName, wheel);
            }

            return(wheel);
        }
        public CarPaintEntity Get(PaintFilter filter)
        {
            var paint = _inMemoryCache.Get(filter.Name);

            if (paint == null)
            {
                paint = _repository.Get(filter);

                _inMemoryCache.Put(filter.Name, paint);
            }

            return(paint);
        }
示例#4
0
        public TyreEntity Get(TyreFilter filter)
        {
            var tyre = _inMemoryCache.Get(filter.WheelManufacturerName);

            if (tyre == null)
            {
                tyre = _repository.Get(filter);

                _inMemoryCache.Put(filter.WheelManufacturerName, tyre);
            }

            return(tyre);
        }
示例#5
0
        public CarEngineEntity Get(EngineFilter filter)
        {
            var engine = _inMemoryCache.Get(filter.ManufacturerName);

            if (engine == null)
            {
                engine = _repository.Get(filter);

                _inMemoryCache.Put(filter.ManufacturerName, engine);
            }

            return(engine);
        }
示例#6
0
    private T TryGetFromMemoryThenFromSource <T>(string key)
    {
        T cacheItem;

        lock (_padlock)
        {
            cacheItem = InMemoryCache.Get <T>(key);
            if (cacheItem == null)
            {
                // Key not in cache, so get data.
                cacheItem = SqlCache.Get <T>(key);
                if (cacheItem != null)
                {
                    InMemoryCache.Put(key, cacheItem);
                }
            }
        }
        return(cacheItem);
    }