internal AggregateExpirationHint GetRoutableClone(PoolManager poolManager, Address sourceNode)
        {
            if (_hints == null || _hints.Count == 0)
            {
                return(null);
            }

            AggregateExpirationHint hint = Create(poolManager);

            NodeExpiration ne = null;

            for (int i = 0; i < _hints.Count; i++)
            {
                ExpirationHint eh = (ExpirationHint)_hints[i];
                if (!eh.IsRoutable && ne == null)
                {
                    ne = NodeExpiration.Create(poolManager, sourceNode);
                    hint.Add(ne);
                }
                else
                {
                    hint.Add(eh);
                }
            }
            return(hint);
        }
Esempio n. 2
0
        internal static ExpirationHint GetExpirationHint(PoolManager poolManager, object dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration)
        {
            ExpirationHint hint = GetExpirationHint(poolManager, absoluteExpiration, slidingExpiration);

            if (hint == null)
            {
                return(GetExpirationHint(poolManager));
            }

            ExpirationHint hint2 = GetExpirationHint(poolManager);

            if (hint2 == null)
            {
                return(hint);
            }


            AggregateExpirationHint aggregateHint = null;

            if (hint2 is AggregateExpirationHint)
            {
                aggregateHint = hint2 as AggregateExpirationHint;
                aggregateHint.Add(hint);

                return(aggregateHint);
            }

            aggregateHint = AggregateExpirationHint.Create(poolManager);
            aggregateHint.Add(hint);
            aggregateHint.Add(hint2);

            return(aggregateHint);
        }
Esempio n. 3
0
        public static ExpirationHint GetExpirationHint(ExpirationPolicy policy, CacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration)
        {
            ExpirationHint hint = GetExpirationHint(policy, absoluteExpiration, slidingExpiration);

            if (hint == null)
            {
                return(GetExpirationHint(dependency));
            }

            ExpirationHint hint2 = GetExpirationHint(dependency);

            if (hint2 == null)
            {
                return(hint);
            }


            AggregateExpirationHint aggregateHint = null;

            if (hint2 is AggregateExpirationHint)
            {
                aggregateHint = hint2 as AggregateExpirationHint;
                aggregateHint.Add(hint);

                return(aggregateHint);
            }

            aggregateHint = new AggregateExpirationHint();
            aggregateHint.Add(hint);
            aggregateHint.Add(hint2);

            return(aggregateHint);
        }
Esempio n. 4
0
        internal AggregateExpirationHint GetRoutableClone(Address sourceNode)
        {
            if (_hints == null || _hints.Count == 0)
            {
                return(null);
            }

            AggregateExpirationHint hint = new AggregateExpirationHint();

            NodeExpiration ne = null;

            for (int i = 0; i < _hints.Count; i++)
            {
                ExpirationHint eh = (ExpirationHint)_hints[i];
                if (!eh.IsRoutable && ne == null)
                {
                    ne = new NodeExpiration(sourceNode);
                    hint.Add(ne);
                }
                else
                {
                    hint.Add(eh);
                }
            }
            return(hint);
        }
Esempio n. 5
0
        private static ExpirationHint GetExpirationHint(CacheDependency cacheDependency, AggregateExpirationHint aggregateHint)
        {
            if (cacheDependency == null)
            {
                return(null);
            }

            ExpirationHint hint = null;

            if (cacheDependency is Runtime.Dependencies.KeyDependency)
            {
                Runtime.Dependencies.KeyDependency keyDependency = cacheDependency as Runtime.Dependencies.KeyDependency;
                hint = new KeyDependency(keyDependency.CacheKeys, new DateTime(keyDependency.StartAfterTicks));

                aggregateHint.Add(hint);
            }


            else if (cacheDependency is Runtime.Dependencies.FileDependency)
            {
                Runtime.Dependencies.FileDependency fileDependency = cacheDependency as Runtime.Dependencies.FileDependency;

                hint = new FileDependency(fileDependency.fileNames, new DateTime(fileDependency.StartAfterTicks));

                aggregateHint.Add(hint);
            }

            else if (cacheDependency is Runtime.Dependencies.DBCacheDependency)
            {
                Runtime.Dependencies.DBCacheDependency dbDependency = cacheDependency as Runtime.Dependencies.DBCacheDependency;

                switch (dbDependency.Type)
                {
                case Runtime.Dependencies.DBDependencyType.OleDbCacheDependency:
                    hint = new OleDbCacheDependency(dbDependency.ConnectionString, dbDependency.PrimaryKey);
                    break;

                case Runtime.Dependencies.DBDependencyType.SqlCacheDependency:
                    hint = new Sql7CacheDependency(dbDependency.ConnectionString, dbDependency.PrimaryKey);
                    break;
                }

                aggregateHint.Add(hint);
            }


            else if (cacheDependency is Runtime.Dependencies.OracleCacheDependency)
            {
                Runtime.Dependencies.OracleCacheDependency oracleDependency = cacheDependency as Runtime.Dependencies.OracleCacheDependency;

                Hashtable parameters = new Hashtable();
                if (oracleDependency.CommandParams != null)
                {
                    foreach (KeyValuePair <string, Runtime.Dependencies.OracleCmdParams> pair in oracleDependency.CommandParams)
                    {
                        Runtime.Dependencies.OracleCmdParams oracleCommandParams = pair.Value;
                        OracleCommandParams commandParam = new OracleCommandParams((OracleCmdParamsType)oracleCommandParams.Type, oracleCommandParams.Value, oracleCommandParams.Direction);
                        parameters.Add(pair.Key, commandParam);
                    }
                }

                hint = new OracleCacheDependency(oracleDependency.ConnectionString, oracleDependency.CommandText, oracleDependency.CommandType, parameters);
                aggregateHint.Add(hint);
            }



            else if (cacheDependency is Runtime.Dependencies.SqlCacheDependency)
            {
                Runtime.Dependencies.SqlCacheDependency sqlDependency = cacheDependency as Runtime.Dependencies.SqlCacheDependency;

                Hashtable parameters = new Hashtable();

                if (sqlDependency.CommandParams != null)
                {
                    foreach (KeyValuePair <string, Runtime.Dependencies.SqlCmdParams> pair in sqlDependency.CommandParams)
                    {
                        Runtime.Dependencies.SqlCmdParams param = pair.Value;

                        Alachisoft.NCache.Caching.AutoExpiration.SqlCmdParams commandParam = new SqlCmdParams();
                        commandParam.CmpInfo                 = param.SqlCmpInfo;
                        commandParam.Direction               = param.SqlParamDir;
                        commandParam.IsNullable              = param.IsNullable;
                        commandParam.LocaleID                = param.LocaleID;
                        commandParam.Offset                  = param.Offset;
                        commandParam.Precision               = param.Precision;
                        commandParam.Scale                   = param.Scale;
                        commandParam.ParamSize               = param.Size;
                        commandParam.SourceColumn            = param.SourceColumn;
                        commandParam.SourceColumnNullMapping = param.SourceColumnNullMapping;
                        commandParam.SqlValue                = param.SqlValue;
                        commandParam.SrcVersion              = param.SrcVersion;
                        commandParam.DbType                  = (SqlDbType)param.Type;
                        commandParam.TypeName                = param.TypeName;
                        commandParam.UdtName                 = param.UdtTypeName;
                        commandParam.Value                   = param.Value;
                        parameters.Add(pair.Key, commandParam);
                    }
                }

                hint = new SqlYukonCacheDependency(sqlDependency.ConnectionString, sqlDependency.CommandText, sqlDependency.CommandType, parameters);
                aggregateHint.Add(hint);
            }


            else if (cacheDependency is Runtime.Dependencies.ExtensibleDependency)
            {
                hint = new ExtensibleDependency(cacheDependency as Runtime.Dependencies.ExtensibleDependency);

                aggregateHint.Add(hint);
            }
            else if (cacheDependency is NosDBDependency)
            {
                NosDBDependency nosDbDependency = cacheDependency as NosDBDependency;
                hint = new NosDBCacheDependency(nosDbDependency.ConnectionString, nosDbDependency.CommandText, nosDbDependency.Timeout, nosDbDependency.Parameters);
                aggregateHint.Add(hint);
            }
            else
            {
                foreach (CacheDependency dep in cacheDependency.Dependencies)
                {
                    hint = GetExpirationHint(dep, aggregateHint);
                }
            }
            IList <ExpirationHint> hints = aggregateHint.Hints;

            if (hints.Count == 0)
            {
                return(null);
            }

            if (hints.Count == 1)
            {
                return(hints[0]);
            }

            return(aggregateHint);
        }