Class RelativeTimeExtensions
- Namespace
- Akavache
- Assembly
- Akavache.dll
Provides extension methods for setting cache expiration times based on relative time intervals from the current time.
- Inheritance
-
Relative
Time Extensions
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
blobCacheIBlobCache The blob cache to store the downloaded data.
urlstringThe URL to download if not already in the cache.
httpMethodHttpMethod The HTTP method to use for the request.
expirationTimeSpan A time span that will be added to the current time to determine expiration.
headersIEnumerable<KeyValue <string, string>>Pair 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
blobCacheIBlobCache The blob cache to store the downloaded data.
urlUriThe URL to download if not already in the cache.
httpMethodHttpMethod The HTTP method to use for the request.
expirationTimeSpan A time span that will be added to the current time to determine expiration.
headersIEnumerable<KeyValue <string, string>>Pair 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
blobCacheIBlobCache The blob cache to insert the item into.
keystringThe key to associate with the cache entry.
databyte[]The data to store in the cache entry.
expirationTimeSpan A 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.
public static IObservable<Unit> InsertObject<T>(this IBlobCache blobCache, string key, T value, TimeSpan expiration)
Parameters
blobCacheIBlobCache The blob cache to insert the item into.
keystringThe key to associate with the cache entry.
valueTThe object to serialize and store in the cache.
expirationTimeSpan A 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.
public static IObservable<Unit> SaveLogin(this ISecureBlobCache blobCache, string user, string password, string host, TimeSpan expiration)
Parameters
blobCacheISecureBlob Cache The blob cache to insert the item into.
userstringThe username to store.
passwordstringThe password to store.
hoststringThe host to store against.
expirationTimeSpan A 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
blobCacheIBlobCache The blob cache containing the items.
keysIEnumerable<string>The keys of the cache entries to update.
expirationTimeSpan A 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
blobCacheIBlobCache The blob cache containing the items.
keysIEnumerable<string>The keys of the cache entries to update.
typeTypeThe type of the cached objects.
expirationTimeSpan A 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
blobCacheIBlobCache The blob cache containing the item.
keystringThe key of the cache entry to update.
expirationTimeSpan A 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
blobCacheIBlobCache The blob cache containing the item.
keystringThe key of the cache entry to update.
typeTypeThe type of the cached object.
expirationTimeSpan A timespan that will be added to the current DateTime.
Returns
- IObservable<Unit>
A signal indicating when the operation is complete.