Table of Contents

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

blobCache IBlobCache

The blob cache to store the downloaded data.

url string

The URL to download if not already in the cache.

httpMethod HttpMethod

The HTTP method to use for the request.

expiration TimeSpan

A time span that will be added to the current time to determine expiration.

headers IEnumerable<KeyValuePair<string, string>>

Optional HTTP headers to include in the request.

fetchAlways bool

A 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

blobCache IBlobCache

The blob cache to store the downloaded data.

url Uri

The URL to download if not already in the cache.

httpMethod HttpMethod

The HTTP method to use for the request.

expiration TimeSpan

A time span that will be added to the current time to determine expiration.

headers IEnumerable<KeyValuePair<string, string>>

Optional HTTP headers to include in the request.

fetchAlways bool

A 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

blobCache IBlobCache

The blob cache to insert the item into.

key string

The key to associate with the cache entry.

data byte[]

The data to store in the cache entry.

expiration TimeSpan

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

blobCache IBlobCache

The blob cache to insert the item into.

key string

The key to associate with the cache entry.

value T

The object to serialize and store in the cache.

expiration TimeSpan

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

T

The 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

blobCache ISecureBlobCache

The blob cache to insert the item into.

user string

The username to store.

password string

The password to store.

host string

The host to store against.

expiration TimeSpan

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

blobCache IBlobCache

The blob cache containing the items.

keys IEnumerable<string>

The keys of the cache entries to update.

expiration TimeSpan

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

blobCache IBlobCache

The blob cache containing the items.

keys IEnumerable<string>

The keys of the cache entries to update.

type Type

The type of the cached objects.

expiration TimeSpan

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

blobCache IBlobCache

The blob cache containing the item.

key string

The key of the cache entry to update.

expiration TimeSpan

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

blobCache IBlobCache

The blob cache containing the item.

key string

The key of the cache entry to update.

type Type

The type of the cached object.

expiration TimeSpan

A timespan that will be added to the current DateTime.

Returns

IObservable<Unit>

A signal indicating when the operation is complete.