Sphyrnidae Common Library  2.0.1
Shared Utilities/Library
Sphyrnidae.Common.Cache.ICache Interface Reference

Storing items in the cache More...

Inheritance diagram for Sphyrnidae.Common.Cache.ICache:
Sphyrnidae.Common.Cache.CacheDistributed Sphyrnidae.Common.Cache.CacheLocal Sphyrnidae.Common.Cache.CacheLocalAndDistributed Sphyrnidae.Common.Cache.CacheNone

Public Member Functions

bool Get< T > (string key, out T item)
 Retrieves an item from the Cache More...
 
void Set< T > (string key, T item)
 Sets an item into cache More...
 
Get< T > (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...
 
Task< T > GetAsync< T > (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...
 
void Remove (string key)
 Removes the given object from cache More...
 
Task< Exception > RemoveAsync (string key)
 Removes the given object from cache More...
 

Properties

CacheOptions Options [get]
 The options for storing items in cache More...
 

Detailed Description

Storing items in the cache

Member Function Documentation

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

T Sphyrnidae.Common.Cache.ICache.Get< T > ( 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

Template Parameters
TThe type of item
Parameters
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

Implemented in Sphyrnidae.Common.Cache.CacheNone, Sphyrnidae.Common.Cache.CacheLocalAndDistributed, Sphyrnidae.Common.Cache.CacheLocal, and Sphyrnidae.Common.Cache.CacheDistributed.

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

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

Retrieves an item from the Cache

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

Implemented in Sphyrnidae.Common.Cache.CacheNone, Sphyrnidae.Common.Cache.CacheLocalAndDistributed, Sphyrnidae.Common.Cache.CacheLocal, and Sphyrnidae.Common.Cache.CacheDistributed.

◆ GetAsync< T >()

Task<T> Sphyrnidae.Common.Cache.ICache.GetAsync< T > ( 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

Template Parameters
TThe type of item
Parameters
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

Implemented in Sphyrnidae.Common.Cache.CacheNone, Sphyrnidae.Common.Cache.CacheLocalAndDistributed, Sphyrnidae.Common.Cache.CacheLocal, and Sphyrnidae.Common.Cache.CacheDistributed.

◆ Remove()

void Sphyrnidae.Common.Cache.ICache.Remove ( string  key)

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 errors in removal of the item will be hidden from the user, so it is preferred to use RemoveAsync if you need this exception handling.

Parameters
keyName of the item in cache

Implemented in Sphyrnidae.Common.Cache.CacheNone, Sphyrnidae.Common.Cache.CacheLocalAndDistributed, Sphyrnidae.Common.Cache.CacheLocal, and Sphyrnidae.Common.Cache.CacheDistributed.

◆ RemoveAsync()

Task<Exception> Sphyrnidae.Common.Cache.ICache.RemoveAsync ( string  key)

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
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.

Implemented in Sphyrnidae.Common.Cache.CacheNone, Sphyrnidae.Common.Cache.CacheLocalAndDistributed, Sphyrnidae.Common.Cache.CacheLocal, and Sphyrnidae.Common.Cache.CacheDistributed.

◆ Set< T >()

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

Sets an item into cache

Template Parameters
TThe type of item
Parameters
keyName of the item in cache
itemThe item being set into cache

Implemented in Sphyrnidae.Common.Cache.CacheNone, Sphyrnidae.Common.Cache.CacheLocalAndDistributed, Sphyrnidae.Common.Cache.CacheLocal, and Sphyrnidae.Common.Cache.CacheDistributed.

Property Documentation

◆ Options

CacheOptions Sphyrnidae.Common.Cache.ICache.Options
get

The options for storing items in cache


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