BuildCache
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
bcache::data_store_t Class Reference

Provide access to a local key/value store. More...

#include <data_store.hpp>

Classes

class  item_t
 A data item. More...
 

Public Member Functions

 data_store_t (const std::string &name)
 Construct a data store. More...
 
void store_item (const std::string &key, const std::string &value, const time::seconds_t timeout)
 Add or overwrite a data item. More...
 
item_t get_item (const std::string &key)
 Get a data item. More...
 
void remove_item (const std::string &key)
 Remove a data item. More...
 
void clear ()
 Clear the data store.
 

Private Member Functions

std::string make_file_path (const std::string &key)
 
void perform_housekeeping ()
 

Private Attributes

std::string m_root_dir
 

Detailed Description

Provide access to a local key/value store.

The key/value store provides a convenient way to store data that is to be shared between multiple BuildCache instances on a local machine.

The values are not stored indefinitely. For instance, the store may be cleared between system sessions, and values that are stored in the data store may have an expiry time after which they are considered invalid.

Constructor & Destructor Documentation

◆ data_store_t()

bcache::data_store_t::data_store_t ( const std::string &  name)

Construct a data store.

Parameters
nameName of the data store.

Member Function Documentation

◆ get_item()

data_store_t::item_t bcache::data_store_t::get_item ( const std::string &  key)

Get a data item.

Parameters
keyThe key of the item to retrieve.
Returns
a valid item if one could be found, or an invalid (empty) item if the requested item could not be found, or if the item expiry time has past.

◆ remove_item()

void bcache::data_store_t::remove_item ( const std::string &  key)

Remove a data item.

Parameters
keyThe ID of the item to retrieve.

◆ store_item()

void bcache::data_store_t::store_item ( const std::string &  key,
const std::string &  value,
const time::seconds_t  timeout 
)

Add or overwrite a data item.

Parameters
keyThe ID of the item to store.
valueThe data to store.
timeoutThe life time of the item.

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