Sphyrnidae Common Library  2.0.1
Shared Utilities/Library
Sphyrnidae.Common.Cache.Caching Class Reference

Wrapper/Helper class around Caching More...

Static Public Member Functions

static bool Get< T > (ICache cache, string key, out T item)
 Retrieves an item from the Cache More...
 
static void Set< T > (ICache cache, string key, T item)
 Sets an item into cache More...
 
static T Get< T > (ICache cache, string key, Func< T > method)
 Attempts to retrieve an item from cache. If not found in cache, will make callback to obtain the item from the caller which will be stored for later use More...
 
static Task< T > GetAsync< T > (ICache cache, string key, Func< Task< T >> method)
 Attempts to retrieve an item from cache. If not found in cache, will make callback to obtain the item from the caller which will be stored for later use More...
 
static void Remove (ICache cache, string key)
 Removes the given object from cache More...
 
static Task< Exception > RemoveAsync (ICache cache, string key)
 Removes the given object from cache More...
 

Detailed Description

Wrapper/Helper class around Caching

Member Function Documentation

◆ Get< T >() [1/2]

static T Sphyrnidae.Common.Cache.Caching.Get< T > ( ICache  cache,
string  key,
Func< T >  method 
)
static

Attempts to retrieve an item from cache. If not found in cache, will make callback to obtain the item from the caller which will be stored for later use

Template Parameters
TThe type of item
Parameters
cacheThe instance of the ICache interface
keyName of the item in cache
methodThe callback function returning the item if not initially found in cache
Returns
The object from cache/callback function

◆ Get< T >() [2/2]

static bool Sphyrnidae.Common.Cache.Caching.Get< T > ( ICache  cache,
string  key,
out T  item 
)
static

Retrieves an item from the Cache

Template Parameters
TThe type of item
Parameters
cacheThe instance of the ICache interface
keyName of the item in cache
itemIf the object is found in the Cache, this will be populated
Returns
True if the object was found, False if not found

◆ GetAsync< T >()

static Task<T> Sphyrnidae.Common.Cache.Caching.GetAsync< T > ( ICache  cache,
string  key,
Func< Task< T >>  method 
)
static

Attempts to retrieve an item from cache. If not found in cache, will make callback to obtain the item from the caller which will be stored for later use

Template Parameters
TThe type of item
Parameters
cacheThe instance of the ICache interface
keyName of the item in cache
methodThe callback function returning the item if not initially found in cache
Returns
The object from cache/callback function

◆ Remove()

static void Sphyrnidae.Common.Cache.Caching.Remove ( ICache  cache,
string  key 
)
static

Removes the given object from cache

Note that this removes from local cache, distributed cache, and via SignalR, all other local cache as well Any exceptions occurring during this process will be hidden

Parameters
cacheThe instance of the ICache interface
keyName of the item in cache

◆ RemoveAsync()

static Task<Exception> Sphyrnidae.Common.Cache.Caching.RemoveAsync ( ICache  cache,
string  key 
)
static

Removes the given object from cache

Note that this removes from local cache, distributed cache, and via SignalR, all other local cache as well

Parameters
cacheThe instance of the ICache interface
keyName of the item in cache
Returns
If an exception was thrown and the item was not fully removed, this exception will be returned. If everything succeeded, this will be null.

◆ Set< T >()

static void Sphyrnidae.Common.Cache.Caching.Set< T > ( ICache  cache,
string  key,
item 
)
static

Sets an item into cache

Template Parameters
TThe type of item
Parameters
cacheThe instance of the ICache interface
keyName of the item in cache
itemThe item being set into cache

The documentation for this class was generated from the following file: