public static IEnumerable <IPRestriction> Get(int tenant)
        {
            var key          = GetCacheKey(tenant);
            var restrictions = cache.Get(key) as List <IPRestriction>;

            if (restrictions == null)
            {
                var lck = locks.GetOrAdd(key, k => new object());
                lock (lck)
                {
                    restrictions = cache.Get(key) as List <IPRestriction>;
                    if (restrictions == null)
                    {
                        restrictions = IPRestrictionsRepository.Get(tenant).ToList();
                        cache.Insert(key, restrictions, cacheExpiration);
                    }

                    object temp;
                    if (locks.TryGetValue(key, out temp) && (temp == lck))
                    {
                        locks.TryRemove(key, out temp);
                    }
                }
            }
            return(restrictions);
        }
        public static IEnumerable <string> Save(IEnumerable <string> ips, int tenant)
        {
            var restrictions = IPRestrictionsRepository.Save(ips, tenant);

            cache.Insert(GetCacheKey(tenant), IPRestrictionsRepository.Get(tenant), cacheExpiration);

            return(restrictions);
        }
        public static IEnumerable <IPRestriction> Get(int tenant)
        {
            var key          = GetCacheKey(tenant);
            var restrictions = cache.Get <List <IPRestriction> >(key);

            if (restrictions == null)
            {
                cache.Insert(key, restrictions = IPRestrictionsRepository.Get(tenant), timeout);
            }
            return(restrictions);
        }