コード例 #1
0
        /// <summary>
        /// Creates a <see cref="Cache{TKey,TValue}"/> instance that is not thread-safe and uses the specified
        /// <see cref="IEqualityComparer{T}"/>.
        /// </summary>
        /// <typeparam name="TKey">The type of the keys.</typeparam>
        /// <typeparam name="TValue">The type of the values.</typeparam>
        /// <param name="invalidationToken">The <see cref="InvalidationToken"/> that can be used to signal a cache invalidation. Must not be <see langword="null" />.</param>
        /// <param name="comparer">The comparer to use for comparing keys. Can be <see langword="null" />.</param>
        /// <returns>
        /// A <see cref="Cache{TKey,TValue}"/> instances for storing keys and values.
        /// </returns>
        public static ICache <TKey, TValue> Create <TKey, TValue> (
            [NotNull] InvalidationToken invalidationToken,
            [CanBeNull] IEqualityComparer <TKey> comparer)
        {
            ArgumentUtility.CheckNotNull("invalidationToken", invalidationToken);

            return(new InvalidationTokenBasedCacheDecorator <TKey, TValue> (new Cache <TKey, TValue> (comparer), invalidationToken));
        }
コード例 #2
0
            internal Revision(long value, InvalidationToken token)
            {
                _value = value;

#if DEBUG
                _tokenReference = new WeakReference <InvalidationToken> (token);
#endif
            }
コード例 #3
0
        public InvalidationTokenBasedCacheDecorator(ICache <TKey, TValue> innerCache, InvalidationToken invalidationToken)
        {
            ArgumentUtility.CheckNotNull("innerCache", innerCache);
            ArgumentUtility.CheckNotNull("invalidationToken", invalidationToken);

            _innerCache        = innerCache;
            _invalidationToken = invalidationToken;
            _revision          = _invalidationToken.GetCurrent();
        }
コード例 #4
0
        /// <summary>
        /// Creates a <see cref="Cache{TKey,TValue}"/> instance that is not thread-safe and uses the <see cref="EqualityComparer{T}.Default"/>
        /// <see cref="IEqualityComparer{T}"/>.
        /// </summary>
        /// <typeparam name="TKey">The type of the keys.</typeparam>
        /// <typeparam name="TValue">The type of the values.</typeparam>
        /// <param name="invalidationToken">The <see cref="InvalidationToken"/> that can be used to signal a cache invalidation. Must not be <see langword="null" />.</param>
        /// <returns>
        /// A <see cref="Cache{TKey,TValue}"/> instance for storing keys and values.
        /// </returns>
        public static ICache <TKey, TValue> Create <TKey, TValue> ([NotNull] InvalidationToken invalidationToken)
        {
            ArgumentUtility.CheckNotNull("invalidationToken", invalidationToken);

            return(new InvalidationTokenBasedCacheDecorator <TKey, TValue> (new Cache <TKey, TValue>(), invalidationToken));
        }