Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/Polly/Caching/AsyncCacheSyntax.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Polly;
#nullable enable
namespace Polly;

public partial class Policy
{
Expand All @@ -13,7 +14,7 @@ public partial class Policy
/// <param name="onCacheError">Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.</param>
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">cacheProvider</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception>? onCacheError = null)
=> CacheAsync(cacheProvider, new RelativeTtl(ttl), DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError);

/// <summary>
Expand All @@ -28,7 +29,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, Tim
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception>? onCacheError = null)
=> CacheAsync(cacheProvider, ttlStrategy, DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError);

/// <summary>
Expand All @@ -44,7 +45,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITt
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
=> CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheError);

/// <summary>
Expand All @@ -61,7 +62,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, Tim
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
{
if (cacheProvider == null) throw new ArgumentNullException(nameof(cacheProvider));
if (ttlStrategy == null) throw new ArgumentNullException(nameof(ttlStrategy));
Expand All @@ -86,7 +87,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITt
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
=> CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy, onCacheError);

/// <summary>
Expand All @@ -103,7 +104,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, Tim
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
{
if (cacheProvider == null) throw new ArgumentNullException(nameof(cacheProvider));
if (ttlStrategy == null) throw new ArgumentNullException(nameof(ttlStrategy));
Expand Down
15 changes: 8 additions & 7 deletions src/Polly/Caching/CacheSyntax.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Polly;
#nullable enable
namespace Polly;

public partial class Policy
{
Expand All @@ -13,7 +14,7 @@ public partial class Policy
/// <param name="onCacheError">Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.</param>
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">cacheProvider</exception>
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception>? onCacheError = null)
=> Cache(cacheProvider, new RelativeTtl(ttl), DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError);

/// <summary>
Expand All @@ -28,7 +29,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl,
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception>? onCacheError = null)
=> Cache(cacheProvider, ttlStrategy, DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError);

/// <summary>
Expand All @@ -44,7 +45,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy t
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
=> Cache(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheError);

/// <summary>
Expand All @@ -61,7 +62,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl,
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
{
if (cacheProvider == null) throw new ArgumentNullException(nameof(cacheProvider));
if (ttlStrategy == null) throw new ArgumentNullException(nameof(ttlStrategy));
Expand All @@ -86,7 +87,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy t
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
=> Cache(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy, onCacheError);

/// <summary>
Expand All @@ -103,7 +104,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl,
/// <exception cref="ArgumentNullException">cacheProvider</exception>
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
{
if (cacheProvider == null) throw new ArgumentNullException(nameof(cacheProvider));
if (ttlStrategy == null) throw new ArgumentNullException(nameof(ttlStrategy));
Expand Down
Loading