示例#1
0
        /// <summary>
        /// <para>Iterator </para>
        /// </summary>
        /// <param name="containerType">
        /// <para>Container type. Recommend using a CacheContainer.</para>
        /// </param>
        /// <param name="keys">
        /// <para>Represents the cache key.</para>
        /// </param>
        public object this[Enum containerType, params string[] keys]
        {
            get
            {
                if (keys == null || keys.Length == 0)
                {
                    return(null);
                }

                ContainerTemplate container = this.GetContainer(containerType);

                if (container == null)
                {
                    return(null);
                }

                container.CheckExpired();

                object ct = container[keys];

                return(ct);
            }
            set
            {
                this.Add(containerType, value, keys);
            }
        }
示例#2
0
        /// <summary>
        /// <para>Clear cache container</para>
        /// </summary>
        /// <param name="containerType">
        /// <para>Container type. Recommend using a CacheContainer.</para>
        /// </param>
        public void Clear(Enum containerType)
        {
            ContainerTemplate container = this.GetContainer(containerType);

            if (container != null)
            {
                container.Clear();
            }
        }
示例#3
0
        /// <summary>
        /// <para>Check all items expired and remove from cache. </para>
        /// </summary>
        /// <param name="containerType">
        /// <para>Container type. Recommend using a CacheContainer.</para>
        /// </param>
        public void CheckExpired(Enum containerType)
        {
            ContainerTemplate container = this.GetContainer(containerType);

            if (container != null)
            {
                container.CheckExpired();
            }
        }
示例#4
0
        /// <summary>
        /// <para>Remove item from cache.</para>
        /// </summary>
        /// <param name="containerType">
        /// <para>Container type. Recommend using a CacheContainer.</para>
        /// </param>
        /// <param name="keys">
        /// <para>Represents the cache key.</para>
        /// </param>
        public void Remove(Enum containerType, params string[] keys)
        {
            ContainerTemplate container = this.GetContainer(containerType);

            if (container != null)
            {
                container.Remove(keys);
            }
        }
示例#5
0
        /// <summary>
        /// <para>Adds item to cache.</para>
        /// </summary>
        /// <param name="containerType">
        /// <para>Container type. Recommend using a CacheContainer.</para>
        /// </param>
        /// <param name="value">
        /// <para>Represents the object to be put in cache.</para>
        /// </param>
        /// <param name="SlideExpiration">
        /// <para>Indicates how long until the cache expires, this time it is renewed every call, ie it indicates how long without calling the item should be removed from the cache.</para>
        /// </param>
        /// <param name="absoluteExpirationTime">
        /// <para>indicates how much time remains in the cache being removed after this period. It will not be used if the parameter SlideExpiration is greater than zero .</para>
        /// </param>
        /// <param name="keys">
        /// <para>Represents the cache key.</para>
        /// </param>
        public void Add(Enum containerType, object value, TimeSpan SlideExpiration, TimeSpan absoluteExpirationTime, params string[] keys)
        {
            ContainerTemplate container = this.GetContainer(containerType);

            if (container.UseContainerTime)
            {
                container.Add(value, container.SlideExpiration, container.AbsoluteExpirationTime, keys);
            }
            else
            {
                container.Add(value, SlideExpiration, absoluteExpirationTime, keys);
            }
        }
示例#6
0
        /// <summary>
        /// <para>Returns total items in cache container.</para>
        /// </summary>
        /// <param name="containerType">
        /// <para>Container type. Recommend using a CacheContainer.</para>
        /// </param>
        /// <returns>
        /// <para>Returns total items in cache container.</para>
        /// </returns>
        public int Count(Enum containerType)
        {
            ContainerTemplate container = this.GetContainer(containerType);

            if (container != null)
            {
                return(container.Count);
            }
            else
            {
                return(0);
            }
        }
示例#7
0
        /// <summary>
        /// <para>Check if cache has item. </para>
        /// </summary>
        /// <param name="containerType">
        /// <para>Container type. Recommend using a CacheContainer.</para>
        /// </param>
        /// <param name="keys">
        /// <para>Represents the cache key.</para>
        /// </param>
        /// <returns>
        /// <para>true if contains at least one item in cache for this key.</para>
        /// </returns>
        public bool ContainsKey(Enum containerType, params string[] keys)
        {
            ContainerTemplate container = this.GetContainer(containerType);

            if (container != null)
            {
                return(container.ContainsKey(keys));
            }
            else
            {
                return(false);
            }
        }