Class RelativeTimeExtensions
- Namespace
- Akavache
- Assembly
- Akavache.dll
Provides extension methods for setting cache expiration times based on relative time intervals from the current time.
public static class RelativeTimeExtensions
- Inheritance
-
RelativeTimeExtensions
Methods
DownloadUrl(IBlobCache, string, HttpMethod, TimeSpan, IEnumerable<KeyValuePair<string, string>>?, bool)
Downloads data from the specified URL if it is not already in the cache, with expiration based on a relative time span.
public static IObservable<byte[]> DownloadUrl(this IBlobCache blobCache, string url, HttpMethod httpMethod, TimeSpan expiration, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false)
Parameters
blobCacheIBlobCacheThe blob cache to store the downloaded data.
urlstringThe URL to download if not already in the cache.
httpMethodHttpMethodThe HTTP method to use for the request.
expirationTimeSpanA time span that will be added to the current time to determine expiration.
headersIEnumerable<KeyValuePair<string, string>>Optional HTTP headers to include in the request.
fetchAlwaysboolA value indicating whether to always fetch from the web, bypassing the cache.
Returns
- IObservable<byte[]>
An observable that emits the downloaded data when available.
DownloadUrl(IBlobCache, Uri, HttpMethod, TimeSpan, IEnumerable<KeyValuePair<string, string>>?, bool)
Downloads data from the specified URL if it is not already in the cache, with expiration based on a relative time span.
public static IObservable<byte[]> DownloadUrl(this IBlobCache blobCache, Uri url, HttpMethod httpMethod, TimeSpan expiration, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false)
Parameters
blobCacheIBlobCacheThe blob cache to store the downloaded data.
urlUriThe URL to download if not already in the cache.
httpMethodHttpMethodThe HTTP method to use for the request.
expirationTimeSpanA time span that will be added to the current time to determine expiration.
headersIEnumerable<KeyValuePair<string, string>>Optional HTTP headers to include in the request.
fetchAlwaysboolA value indicating whether to always fetch from the web, bypassing the cache.
Returns
- IObservable<byte[]>
An observable that emits the downloaded data when available.
Insert(IBlobCache, string, byte[], TimeSpan)
Inserts an item into the cache with expiration based on a relative time span.
public static IObservable<Unit> Insert(this IBlobCache blobCache, string key, byte[] data, TimeSpan expiration)
Parameters
blobCacheIBlobCacheThe blob cache to insert the item into.
keystringThe key to associate with the cache entry.
databyte[]The data to store in the cache entry.
expirationTimeSpanA time span that will be added to the current time to determine expiration.
Returns
- IObservable<Unit>
An observable that signals when the item is added to the cache.
InsertObject<T>(IBlobCache, string, T, TimeSpan)
Inserts an object into the cache with expiration based on a relative time span.
[RequiresUnreferencedCode("Using InsertObject requires types to be preserved for serialization")]
[RequiresDynamicCode("Using InsertObject requires types to be preserved for serialization")]
public static IObservable<Unit> InsertObject<T>(this IBlobCache blobCache, string key, T value, TimeSpan expiration)
Parameters
blobCacheIBlobCacheThe blob cache to insert the item into.
keystringThe key to associate with the cache entry.
valueTThe object to serialize and store in the cache.
expirationTimeSpanA time span that will be added to the current time to determine expiration.
Returns
- IObservable<Unit>
An observable that signals when the item is added to the cache.
Type Parameters
TThe type of object to insert.
SaveLogin(ISecureBlobCache, string, string, string, TimeSpan)
Saves a username and password.
[RequiresUnreferencedCode("Using SaveLogin requires types to be preserved for serialization")]
[RequiresDynamicCode("Using SaveLogin requires types to be preserved for serialization")]
public static IObservable<Unit> SaveLogin(this ISecureBlobCache blobCache, string user, string password, string host, TimeSpan expiration)
Parameters
blobCacheISecureBlobCacheThe blob cache to insert the item into.
userstringThe username to store.
passwordstringThe password to store.
hoststringThe host to store against.
expirationTimeSpanA timespan that will be added to the current DateTime.
Returns
- IObservable<Unit>
A observable which will signal when the item is added.
UpdateExpiration(IBlobCache, IEnumerable<string>, TimeSpan)
Updates the expiration date for multiple existing cache entries without reading or writing the cached data. This is useful when a server returns a NotModified response and you want to extend the cache expiration.
public static IObservable<Unit> UpdateExpiration(this IBlobCache blobCache, IEnumerable<string> keys, TimeSpan expiration)
Parameters
blobCacheIBlobCacheThe blob cache containing the items.
keysIEnumerable<string>The keys of the cache entries to update.
expirationTimeSpanA timespan that will be added to the current DateTime.
Returns
- IObservable<Unit>
A signal indicating when the operation is complete.
UpdateExpiration(IBlobCache, IEnumerable<string>, Type, TimeSpan)
Updates the expiration date for multiple existing cache entries without reading or writing the cached data. This is useful when a server returns a NotModified response and you want to extend the cache expiration.
public static IObservable<Unit> UpdateExpiration(this IBlobCache blobCache, IEnumerable<string> keys, Type type, TimeSpan expiration)
Parameters
blobCacheIBlobCacheThe blob cache containing the items.
keysIEnumerable<string>The keys of the cache entries to update.
typeTypeThe type of the cached objects.
expirationTimeSpanA timespan that will be added to the current DateTime.
Returns
- IObservable<Unit>
A signal indicating when the operation is complete.
UpdateExpiration(IBlobCache, string, TimeSpan)
Updates the expiration date for an existing cache entry without reading or writing the cached data. This is useful when a server returns a NotModified response and you want to extend the cache expiration.
public static IObservable<Unit> UpdateExpiration(this IBlobCache blobCache, string key, TimeSpan expiration)
Parameters
blobCacheIBlobCacheThe blob cache containing the item.
keystringThe key of the cache entry to update.
expirationTimeSpanA timespan that will be added to the current DateTime.
Returns
- IObservable<Unit>
A signal indicating when the operation is complete.
UpdateExpiration(IBlobCache, string, Type, TimeSpan)
Updates the expiration date for an existing cache entry without reading or writing the cached data. This is useful when a server returns a NotModified response and you want to extend the cache expiration.
public static IObservable<Unit> UpdateExpiration(this IBlobCache blobCache, string key, Type type, TimeSpan expiration)
Parameters
blobCacheIBlobCacheThe blob cache containing the item.
keystringThe key of the cache entry to update.
typeTypeThe type of the cached object.
expirationTimeSpanA timespan that will be added to the current DateTime.
Returns
- IObservable<Unit>
A signal indicating when the operation is complete.