Class ResilientBrowsingCache
Resilient Cache.
Inheritance
Inherited Members
Namespace: Gee.External.Browsing.Cache
Assembly: Gee.External.Browsing.dll
Syntax
public sealed class ResilientBrowsingCache : IBrowsingCache, IDisposable
Remarks
Represents a resilient cache that automatically retries failed operations performed on a IBrowsingCache. The number of retry attempts is either caller or implementation specific if you do not specify a value. Between each retry attempt, the resilient cache will pause for an implementation specific interval. If all retry attempts are exhausted and the attempted operation never succeeds, the exception the failed operation threw will be propagated up to you.
If you specify a number of retry attempts when you create a resilient cache, be practical with the value you specify. The resilient cache will pause for an implementation specific interval between each retry attempt, which effectively means if an attempted operation always fails, the exception it threw will not be propagated up to you until all the retry attempts are exhausted. If you specify a very high number of retry attempts, this could have self inflicted performance implications.
When you create a resilient cache, you can specify whether or not it takes ownership of the cache you want to proxy to and dispose it when the resilient cache itself is disposed. The recommended behavior is that you allow the resilient cache to take ownership of the cache you want to proxy to but take note that if you reference or dispose the cache you want to proxy to after you create the resilient cache, the behavior of the resilient cache and cache you want to proxy to is undefined.
Since a resilient cache itself implements IBrowsingCache, it is technically possible to create a new resilient cache for an existing resilient cache, though the reasons for doing so, in most cases, are unjustified. To avoid doing do, consider creating a resilient cache using Create(IBrowsingCache), or one of its overloads, instead of one of the constructor overloads. Create(IBrowsingCache) will conveniently create a resilient cache if, and only if, the cache you want to proxy to itself is not a resilient cache.
Constructors
ResilientBrowsingCache(IBrowsingCache)
Create a Resilient Cache.
Declaration
public ResilientBrowsingCache(IBrowsingCache cache)
Parameters
Type | Name | Description |
---|---|---|
IBrowsingCache | cache | A IBrowsingCache to proxy to. The resilient cache takes ownership of
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
ResilientBrowsingCache(IBrowsingCache, Int32)
Create a Resilient Cache.
Declaration
public ResilientBrowsingCache(IBrowsingCache cache, int retryAttempts)
Parameters
Type | Name | Description |
---|---|---|
IBrowsingCache | cache | A IBrowsingCache to proxy to. The resilient cache takes ownership of
|
System.Int32 | retryAttempts | The number of attempts a failed operation should be retried. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.ArgumentOutOfRangeException | Thrown if |
ResilientBrowsingCache(IBrowsingCache, Int32, Boolean)
Create a Resilient Cache.
Declaration
public ResilientBrowsingCache(IBrowsingCache cache, int retryAttempts, bool ownCache)
Parameters
Type | Name | Description |
---|---|---|
IBrowsingCache | cache | A IBrowsingCache to proxy to. |
System.Int32 | retryAttempts | The number of attempts a failed operation should be retried. |
System.Boolean | ownCache | A boolean flag indicating whether or not the resilient cache takes ownership of
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.ArgumentOutOfRangeException | Thrown if |
Methods
Create(IBrowsingCache)
Create a Resilient Cache.
Declaration
public static ResilientBrowsingCache Create(IBrowsingCache cache)
Parameters
Type | Name | Description |
---|---|---|
IBrowsingCache | cache | A IBrowsingCache to proxy to. The resilient cache takes ownership of
|
Returns
Type | Description |
---|---|
ResilientBrowsingCache | A resilient cache. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
Create(IBrowsingCache, Int32)
Create a Resilient Cache.
Declaration
public static ResilientBrowsingCache Create(IBrowsingCache cache, int retryAttempts)
Parameters
Type | Name | Description |
---|---|---|
IBrowsingCache | cache | A IBrowsingCache to proxy to. The resilient cache takes ownership of
|
System.Int32 | retryAttempts | The number of attempts a failed operation should be retried. |
Returns
Type | Description |
---|---|
ResilientBrowsingCache | A resilient cache. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.ArgumentOutOfRangeException | Thrown if |
Create(IBrowsingCache, Int32, Boolean)
Create a Resilient Cache.
Declaration
public static ResilientBrowsingCache Create(IBrowsingCache cache, int retryAttempts, bool ownCache)
Parameters
Type | Name | Description |
---|---|---|
IBrowsingCache | cache | A IBrowsingCache to proxy to. |
System.Int32 | retryAttempts | The number of attempts a failed operation should be retried. |
System.Boolean | ownCache | A boolean flag indicating whether or not the resilient cache takes ownership of
|
Returns
Type | Description |
---|---|
ResilientBrowsingCache | A resilient cache. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.ArgumentOutOfRangeException | Thrown if |
Dispose()
Dispose Object.
Declaration
public void Dispose()
GetSafeCacheEntryAsync(String, CancellationToken)
Get a Safe Cache Entry Asynchronously.
Declaration
public Task<SafeCacheEntry> GetSafeCacheEntryAsync(string threatSha256HashPrefix, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | threatSha256HashPrefix | A SHA256 hash prefix, formatted as a hexadecimal encoded string, identifying a threat to retrieve from the cache. |
System.Threading.CancellationToken | cancellationToken | A cancellation token to cancel the asynchronous operation with. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SafeCacheEntry> | The SafeCacheEntry cached for the threat identified by
|
Exceptions
Type | Condition |
---|---|
BrowsingCacheException | Thrown if a caching error occurs. |
System.ArgumentNullException | Thrown if |
System.ObjectDisposedException | Thrown if the object is disposed. |
System.OperationCanceledException | Thrown if the asynchronous operation is cancelled. |
GetUnsafeCacheEntryAsync(String, CancellationToken)
Get an Unsafe Cache Entry Asynchronously.
Declaration
public Task<UnsafeCacheEntry> GetUnsafeCacheEntryAsync(string threatSha256Hash, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | threatSha256Hash | A full SHA256 hash, formatted as a hexadecimal encoded string, identifying a threat to retrieve from the cache. |
System.Threading.CancellationToken | cancellationToken | A cancellation token to cancel the asynchronous operation with. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<UnsafeCacheEntry> | The UnsafeCacheEntry cached for the threat identified by
|
Exceptions
Type | Condition |
---|---|
BrowsingCacheException | Thrown if a caching error occurs. |
System.ArgumentNullException | Thrown if |
System.ObjectDisposedException | Thrown if the object is disposed. |
System.OperationCanceledException | Thrown if the asynchronous operation is cancelled. |
PutSafeCacheEntryAsync(SafeCacheEntry, CancellationToken)
Put a Safe Cache Entry Asynchronously.
Declaration
public Task PutSafeCacheEntryAsync(SafeCacheEntry safeCacheEntry, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
SafeCacheEntry | safeCacheEntry | A SafeCacheEntry to cache. |
System.Threading.CancellationToken | cancellationToken | A cancellation token to cancel the asynchronous operation with. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
BrowsingCacheException | Thrown if a caching error occurs. |
System.ArgumentNullException | Thrown if |
System.ObjectDisposedException | Thrown if the object is disposed. |
System.OperationCanceledException | Thrown if the asynchronous operation is cancelled. |
PutUnsafeCacheEntryAsync(UnsafeCacheEntry, CancellationToken)
Put an Unsafe Cache Entry Asynchronously.
Declaration
public Task PutUnsafeCacheEntryAsync(UnsafeCacheEntry unsafeCacheEntry, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
UnsafeCacheEntry | unsafeCacheEntry | An UnsafeCacheEntry to cache. |
System.Threading.CancellationToken | cancellationToken | A cancellation token to cancel the asynchronous operation with. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
BrowsingCacheException | Thrown if a caching error occurs. |
System.ArgumentNullException | Thrown if |
System.ObjectDisposedException | Thrown if the object is disposed. |
System.OperationCanceledException | Thrown if the asynchronous operation is cancelled. |
RemoveSafeCacheEntryAsync(String, CancellationToken)
Remove a Safe Cache Entry Asynchronously.
Declaration
public Task RemoveSafeCacheEntryAsync(string threatSha256HashPrefix, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | threatSha256HashPrefix | A SHA256 hash prefix, formatted as a hexadecimal encoded string, identifying a threat to remove from the cache. |
System.Threading.CancellationToken | cancellationToken | A cancellation token to cancel the asynchronous operation with. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
BrowsingCacheException | Thrown if a caching error occurs. |
System.ArgumentNullException | Thrown if |
System.ObjectDisposedException | Thrown if the object is disposed. |
System.OperationCanceledException | Thrown if the asynchronous operation is cancelled. |
RemoveUnsafeCacheEntryAsync(String, CancellationToken)
Remove an Unsafe Cache Entry Asynchronously.
Declaration
public Task RemoveUnsafeCacheEntryAsync(string threatSha256Hash, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | threatSha256Hash | A full SHA256 hash, formatted as a hexadecimal encoded string, identifying a threat to remove from the cache. |
System.Threading.CancellationToken | cancellationToken | A cancellation token to cancel the asynchronous operation with. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
BrowsingCacheException | Thrown if a caching error occurs. |
System.ArgumentNullException | Thrown if |
System.ObjectDisposedException | Thrown if the object is disposed. |
System.OperationCanceledException | Thrown if the asynchronous operation is cancelled. |