public void Put(String topic, RoutingInfo routingInfo)
        {
            lock (_cacheLock)
            {
                // creating a new cache policy each time is annoying, but necessary
                // see: http://stackoverflow.com/questions/16972641/expiring-a-cached-item-via-cacheitempolicy-in-net-memorycache
                CacheItemPolicy expirationPolicy = new CacheItemPolicy()
                {
                    AbsoluteExpiration = new DateTimeOffset(DateTime.UtcNow.AddSeconds(_cacheExpiryInSeconds))
                };

                _routingInfoCache.Add(new CacheItem(topic, routingInfo), expirationPolicy);
            }
        }
示例#2
0
        public static bool IsNullOrEmpty(this RoutingInfo routing)
        {
            bool isNullOrEmpty = false;

            if (null == routing)
            {
                isNullOrEmpty = true;
            }
            else if (null == routing.Routes)
            {
                isNullOrEmpty = true;
            }
            else if (!routing.Routes.Any())
            {
                isNullOrEmpty = true;
            }

            return(isNullOrEmpty);
        }