Пример #1
0
        /// <summary>
        /// Updates the expiry for the specified <paramref name="key"/>.
        /// </summary>
        /// <param name="cache">The cache to use.</param>
        /// <param name="key">The key to update.</param>
        /// <param name="expiry">The expiry of the <paramref name="key"/>.</param>
        /// <param name="throwIfExpired">If set to <c>true</c>, a <see cref="KeyHasExpiredException{TKey}"/> will be thrown if the <paramref name="key"/> has expired upon subscription.</param>
        /// <param name="scheduler">Scheduler to perform the update on.</param>
        /// <returns>
        /// An observable stream that, when done, returns an <see cref="Unit" />.
        /// </returns>
        public static IObservable <KeyValuePair <TKey, TValue> > UpdateExpiry <TKey, TValue>(this IObservableCache <TKey, TValue> cache, TKey key, TimeSpan expiry, bool throwIfExpired = true, IScheduler scheduler = null)
        {
            if (cache == null)
            {
                throw new ArgumentNullException(nameof(cache));
            }
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            return(cache.UpdateExpiry(Observable.Return(new KeyValuePair <TKey, TimeSpan>(key, expiry)), throwIfExpired, scheduler));
        }