Oddity
Oddity.Cache.CacheService< TData > Class Template Reference

Represents an cache service used to manage cached data. More...

Public Member Functions

 CacheService (int lifetimeSeconds)
 Initializes a new instance of the CacheService<TData> class. More...
 
bool GetIfAvailable (out TData data, string parameter)
 Checks if there is a cached model with the specified parameter. If yes, then appropriate flag is returned and out parameter is filled. More...
 
bool GetListIfAvailable (out List< TData > data, string parameter)
 Checks if there is a cached list of models with the specified parameter. If yes, then appropriate flag is returned and out parameter is filled. More...
 
void Update (TData data, string parameter)
 Updates a model with the specified parameter. More...
 
void UpdateList (List< TData > data, string parameter)
 Updates a list of models with the specified parameter. More...
 
int Clear ()
 Clears all cached data. More...
 

Properties

int LifetimeSeconds [get, set]
 Gets or sets the number of seconds after which the data should be updated (retrieved from API again). More...
 

Detailed Description

Represents an cache service used to manage cached data.

Template Parameters
TDataType of the cached data.
Type Constraints
TData :ModelBase 
TData :IIdentifiable 

Constructor & Destructor Documentation

Oddity.Cache.CacheService< TData >.CacheService ( int  lifetimeSeconds)

Initializes a new instance of the CacheService<TData> class.

Parameters
lifetimeSecondsThe number of seconds after which the data should be updated (retrieved from API again).

Member Function Documentation

int Oddity.Cache.CacheService< TData >.Clear ( )

Clears all cached data.

Returns
Number of purged cached elements.
bool Oddity.Cache.CacheService< TData >.GetIfAvailable ( out TData  data,
string  parameter 
)

Checks if there is a cached model with the specified parameter. If yes, then appropriate flag is returned and out parameter is filled.

Parameters
dataOut parameter which will be used to return cached model (or null if the parameter is new).
parameterThe parameter used for the identification of the cached model.
Returns
True if the cached model has been found and returned in the out parameter, otherwise false.
bool Oddity.Cache.CacheService< TData >.GetListIfAvailable ( out List< TData >  data,
string  parameter 
)

Checks if there is a cached list of models with the specified parameter. If yes, then appropriate flag is returned and out parameter is filled.

Parameters
dataOut parameter which will be used to return cached list of models (or null if the parameter is new).
parameterThe parameter used for the identification of the cached list of models.
Returns
True if the cached list of models has been found and returned in the out parameter, otherwise false.
void Oddity.Cache.CacheService< TData >.Update ( TData  data,
string  parameter 
)

Updates a model with the specified parameter.

Parameters
dataThe model which will be cached.
parameterThe parameter used for model identification.
void Oddity.Cache.CacheService< TData >.UpdateList ( List< TData >  data,
string  parameter 
)

Updates a list of models with the specified parameter.

Parameters
dataThe list of models which will be cached.
parameterThe parameter used for list of models identification.

Property Documentation

int Oddity.Cache.CacheService< TData >.LifetimeSeconds
getset

Gets or sets the number of seconds after which the data should be updated (retrieved from API again).


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