Skip to content

Method GetOrCreate<T> ​

Namespace: Belay.Core
Assembly: Belay.Core.dll

GetOrCreate<T>(string, Func<T>) ​

Gets a cached value or creates it using the factory function.

csharp
public static T GetOrCreate<T>(string key, Func<T> factory)

Parameters ​

key string

The cache key.

factory Func<T>

The factory function to create the value if not cached.

Returns ​

T

The cached or newly created value.

Type Parameters ​

T

The type of the cached value.

Exceptions ​

ArgumentNullException

Thrown when key or factory is null.

Released under the Apache License 2.0.