Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ticks"></param>
        /// <param name="isSliding"></param>
        /// <returns></returns>
        ///
        public static ExpirationHint MakeExpirationHint(PoolManager poolManger, long ticks, bool isAbsolute)
        {
            if (ticks == 0)
            {
                return(null);
            }
            IdleExpiration idleExpiration = null;

            if (!isAbsolute)
            {
                TimeSpan slidingExpiration = new TimeSpan(ticks);


                if (slidingExpiration.CompareTo(TimeSpan.Zero) < 0)
                {
                    throw new ArgumentOutOfRangeException("slidingExpiration");
                }

                if (slidingExpiration.CompareTo(DateTime.Now.AddYears(1) - DateTime.Now) >= 0)
                {
                    throw new ArgumentOutOfRangeException("slidingExpiration");
                }


                idleExpiration = IdleExpiration.Create(poolManger, slidingExpiration);
                return(idleExpiration);
            }
            else
            {
                DateTime absoluteExpiration = new DateTime(ticks, DateTimeKind.Utc);
                return(FixedExpiration.Create(poolManger, absoluteExpiration));
            }
        }
Exemplo n.º 2
0
        internal Subscriptions(string clientId, string subscriptionId, SubscriptionPolicyType subscriptionPolicy, long expirationTime, CacheRuntimeContext context, SubscriptionType subscriptionType = SubscriptionType.Subscriber)
        {
            _clientId           = clientId;
            _subscriptionPolicy = subscriptionPolicy;
            _context            = context;
            _expiration         = IdleExpiration.Create(null, new TimeSpan(expirationTime));

            _subscriptionType = subscriptionType;
            _expirationTime   = expirationTime;
        }
Exemplo n.º 3
0
        public static ExpirationHint GetExpirationHintObj(PoolManager poolManager, Alachisoft.NCache.Common.Protobuf.Dependency dependency, long absoluteExpiration, long slidingExpiration, bool resyncOnExpiration, string serializationContext)
        {
            ExpirationHint hint = null;

            //We expect Web.Cache to send in UTC DateTime, AbsoluteExpiration is dealt in UTC
            if (absoluteExpiration != Common.Util.Time.MaxUniversalTicks && absoluteExpiration != 0 && absoluteExpiration != 1 && absoluteExpiration != 2)
            {
                hint = FixedExpiration.Create(poolManager, new DateTime(absoluteExpiration, DateTimeKind.Utc));
            }

            if (slidingExpiration != 0 && slidingExpiration != 1 && slidingExpiration != 2)
            {
                hint = IdleExpiration.Create(poolManager, new TimeSpan(slidingExpiration));
            }

            ExpirationHint depHint = GetExpirationHintObj(poolManager, dependency, false, serializationContext);

            if (depHint != null)
            {
                if (hint != null)
                {
                    if (depHint is AggregateExpirationHint)
                    {
                        ((AggregateExpirationHint)depHint).Add(hint);
                        hint = depHint;
                    }
                    else
                    {
                        hint = AggregateExpirationHint.Create(poolManager, hint, depHint);
                    }
                }
                else
                {
                    hint = depHint;
                }
            }
            if (hint != null && resyncOnExpiration)
            {
                hint.SetBit(ExpirationHint.NEEDS_RESYNC);
            }
            return(hint);
        }