Exemplo n.º 1
0
        /// <summary>
        /// Gets a TemporaryObject&lt;T&gt;, using the specified name, sliding expiration and
        /// creation delegate.
        /// </summary>
        /// <param name="name">The name of the temporary object.</param>
        /// <param name="sliding_expiration_seconds">The interval between the time the <see cref="TemporaryObject&lt;T&gt;"/>
        /// object was last accessed and the time at which that object expires. If this value is the equivalent of 20 minutes, the object
        /// expires and is removed from the internal cache 20 minutes after it is las accessed.</param>
        /// <param name="create_object_delegate">An delegate that can be used to instantiate the temporary object if it
        /// does not exist.</param>
        public static T Get(string name, int sliding_expiration_seconds, TemporaryObjectCreationDelegate create_object_delegate)
        {
            T temp = GetAndCreateIfNotExist(name, create_object_delegate);

            NCache.Add(name, create_object_delegate, sliding_expiration_seconds);
            return(temp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a TemporaryObject&lt;<paramref name="T"/>&gt;, using the specified name and creation delegate.
        /// </summary>
        /// <param name="name">The name of the temporary object.</param>
        /// <param name="create_object_delegate">An delegate that can be used to instantiate the temporary object if it
        /// does not exist.</param>
        /// <returns></returns>
        public static T Get(string name, TemporaryObjectCreationDelegate create_object_delegate)
        {
            T temp = GetAndCreateIfNotExist(name, create_object_delegate);

            NCache.Add(name, create_object_delegate);
            return(temp);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a TemporaryObject&lt;T&gt;, using the specified name, sliding expiration and
        /// creation delegate.
        /// </summary>
        /// <param name="name">The name of the temporary object.</param>
        /// <param name="absolute_expiration">The time at which the temporary object expires and is removed from the internal
        /// cache.</param>
        /// <param name="create_object_delegate">An delegate that can be used to instantiate the temporary object if it
        /// does not exist.</param>
        public static T Get(string name, DateTime absolute_expiration, TemporaryObjectCreationDelegate create_object_delegate)
        {
            T temp = GetAndCreateIfNotExist(name, create_object_delegate);

            NCache.Insert(name, temp, null, absolute_expiration, CacheItemPriority.Normal, null);
            return(temp);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets a TemporaryObject&lt;<paramref name="T"/>&gt;, using the specified name.
        /// </summary>
        /// <param name="name">The name of the object to get.</param>
        /// <returns>A object of the type <paramref name="T"/> or null if the name was not found.</returns>
        public static T Get(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            T temp = NCache.Get(kCachePrefix + name) as T;

            return(temp);
        }