Skip to content

},System.Nullable{System.DateTimeOffset})} },System.Nullable{System.DateTimeOffset})}

JsonSerializationMixin.GetOrFetchObject(IBlobCache, string, Func>, DateTimeOffset?) method

Defined in

Type: JsonSerializationMixin Namespace: Akavache Assembly: Akavache.Core.dll

Applies to

net9.0, net9.0-maccatalyst18.0, net9.0-macos15.0, net9.0-tvos18.0, net9.0-android35.0, net9.0-ios18.0, net8.0, net8.0-android34.0, net8.0-macos14.5, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-macos15.0, net8.0-tvos18.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-tvos17.2, netstandard2.1, netstandard2.0

Overloads

  • 1. public static IObservable<T?> GetOrFetchObject<T>(this IBlobCache blobCache, string key, Func<IObservable<T>> fetchFunc, DateTimeOffset? absoluteExpiration = null)
  • 2. public static IObservable<T?> GetOrFetchObject<T>(this IBlobCache blobCache, string key, Func<Task<T>> fetchFunc, DateTimeOffset? absoluteExpiration = null)

1. Overload

public static IObservable<T?> GetOrFetchObject<T>(this IBlobCache blobCache, string key, Func<IObservable<T>> fetchFunc, DateTimeOffset? absoluteExpiration = null)

View source

Summary: Attempt to return an object from the cache. If the item doesn't exist or returns an error, call a Func to return the latest version of an object and insert the result in the cache.

For most Internet applications, this method is the best method to call to fetch static data (i.e. images) from the network.

Type parameters

NameDescription
TThe type of item to get.

Parameters

NameTypeDescription
blobCache[IBlobCache](#The cache to get the item.
keystringThe key to associate with the object.
fetchFuncFunc>A Func which will asynchronously return the latest value for the object should the cache not contain the key. Observable.Start is the most straightforward way (though not the most efficient!) to implement this Func.
absoluteExpiration = nullDateTimeOffset?An optional expiration date.

Returns: IObservable -- A Future result representing the deserialized object from the cache.

2. Overload

public static IObservable<T?> GetOrFetchObject<T>(this IBlobCache blobCache, string key, Func<Task<T>> fetchFunc, DateTimeOffset? absoluteExpiration = null)

View source

Summary: Attempt to return an object from the cache. If the item doesn't exist or returns an error, call a Func to return the latest version of an object and insert the result in the cache.

For most Internet applications, this method is the best method to call to fetch static data (i.e. images) from the network.

Type parameters

NameDescription
TThe type of item to get.

Parameters

NameTypeDescription
blobCache[IBlobCache](#The cache to get the item.
keystringThe key to associate with the object.
fetchFuncFunc>A Func which will asynchronously return the latest value for the object should the cache not contain the key.
absoluteExpiration = nullDateTimeOffset?An optional expiration date.

Returns: IObservable -- A Future result representing the deserialized object from the cache.