neic-glass3  1.4.6
Public Member Functions | List of all members
glass3::util::Cache Class Reference

glass3::util::Cache class - a thread safe in-memory cache More...

#include <cache.h>

Inheritance diagram for glass3::util::Cache:
Inheritance graph
Collaboration diagram for glass3::util::Cache:
Collaboration graph

Public Member Functions

 Cache ()
 Cache constructor. More...
 
virtual ~Cache ()
 Cache destructor. More...
 
void clear () override
 Cache clear function. More...
 
virtual bool addToCache (std::shared_ptr< json::Object > data, std::string id)
 add data to Cache More...
 
virtual bool removeFromCache (std::string id)
 remove data from Cache More...
 
virtual bool isInCache (std::string id)
 check for data in Cache More...
 
virtual std::shared_ptr< const json::Object > getFromCache (std::string id)
 get data from Cache More...
 
virtual std::shared_ptr< const json::Object > getNextFromCache (bool restart=false)
 get next data from Cache More...
 
virtual bool isEmpty ()
 check if Cache empty More...
 
int size ()
 Retrieves the current size of the Cache. More...
 
- Public Member Functions inherited from glass3::util::BaseClass
 BaseClass ()
 BaseClass constructor. More...
 
virtual ~BaseClass ()
 BaseClass destructor. More...
 
virtual bool setup (std::shared_ptr< const json::Object > config)
 BaseClass configuration function. More...
 
const std::shared_ptr< const json::Object > getConfig ()
 
bool getSetup ()
 Retrieves the class member boolean flag indicating whether the class has been setup, set to true if setup was successful. More...
 
const std::string & getDefaultAgencyId ()
 Function to retrieve the name of the default agency id. More...
 
void setDefaultAgencyId (const std::string &id)
 Function to set the name of the default agency id. More...
 
const std::string & getDefaultAuthor ()
 Function to retrieve the name of the default author. More...
 
void setDefaultAuthor (const std::string &author)
 Function to set the name of the default author. More...
 

Additional Inherited Members

- Protected Attributes inherited from glass3::util::BaseClass
std::shared_ptr< const json::Object > m_Config
 A shared pointer to the json::Object that holds the configuration. More...
 
std::atomic< bool > m_bIsSetup
 the boolean flag indicating whether the class has been setup, set to true if setup was successful. More...
 
std::string m_DefaultAgencyID
 A std::string containing the default agency id to use in parsing if one is not provided. More...
 
std::string m_DefaultAuthor
 A std::string containing the default author to use in parsing if one is not provided. More...
 

Detailed Description

glass3::util::Cache class - a thread safe in-memory cache

The glass3::util::Cache class is a class implementing an in-memory cache of shared_ptr's to json::Objects as a std::map. The cache supports iteration, and is thread safe.

Cache inherits from the baseclass class.

Constructor & Destructor Documentation

glass3::util::Cache::Cache ( )

Cache constructor.

The Cache for the lookup class. Initializes members to default values.

glass3::util::Cache::~Cache ( )
virtual

Cache destructor.

The destructor for the Cache class.

Member Function Documentation

bool glass3::util::Cache::addToCache ( std::shared_ptr< json::Object >  data,
std::string  id 
)
virtual

add data to Cache

Add the provided data identified by the provided id to the Cache

Parameters
data- A pointer to a json::Object to add to the Cache
id- A std::string that contains the key that identifies the data to add
Returns
returns true if successful, false otherwise.
void glass3::util::Cache::clear ( )
overridevirtual

Cache clear function.

The clear function for the Cache class. Clear all data currently contained in the Cache

Reimplemented from glass3::util::BaseClass.

std::shared_ptr< const json::Object > glass3::util::Cache::getFromCache ( std::string  id)
virtual

get data from Cache

Get the data identified by the provided id from the Cache

Parameters
id- A std::string that contains the key that identifies the data to get
Returns
returns a pointer to the json::Object containing the data, NULL if the data was not found
std::shared_ptr< const json::Object > glass3::util::Cache::getNextFromCache ( bool  restart = false)
virtual

get next data from Cache

Gets the next data available from the Cache

Parameters
restart- A boolean flag indicating whether to start at the beginning of the Cache
Returns
returns a pointer to the json::Object containing the next data, NULL if there is no more data available.
bool glass3::util::Cache::isEmpty ( )
virtual

check if Cache empty

Check to see if the Cache is empty

Returns
returns true if empty, false otherwise.
bool glass3::util::Cache::isInCache ( std::string  id)
virtual

check for data in Cache

Check to see if the data identified by the provided id is in the Cache

Parameters
id- A std::string that contains the key that identifies the data to remove
Returns
returns true if successful, false otherwise.
bool glass3::util::Cache::removeFromCache ( std::string  id)
virtual

remove data from Cache

Remove the data identified by the provided id from the Cache

Parameters
id- A std::string that contains the key that identifies the data to remove
Returns
returns true if successful, false otherwise.
int glass3::util::Cache::size ( )

Retrieves the current size of the Cache.


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