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);
        }