PMDA++  0.4.4
Header-only C++ library for writing PCP PMDAs
Classes | Enumerations | Functions
pcp::cache Namespace Reference

Classes

struct  lookup_result_type
 Structure for return results from pcp::cache::lookup functions. More...
 

Enumerations

enum  lookup_flags { require_active = 0x1 }
 Flags that may be applied to cache lookups. More...
 

Functions

lookup_flags operator| (lookup_flags a, lookup_flags b)
 Pipe operator for combining lookup_flags values. More...
 
template<typename Type >
lookup_result_type< Type > lookup (const pmInDom indom, const instance_id_type instance_id, const lookup_flags flags=require_active)
 Lookup a cache entry, by instance ID. More...
 
template<typename Type >
lookup_result_type< Type > lookup (const pmInDom indom, const std::string &name, const lookup_flags flags=require_active)
 Lookup a cache entry, by instance name. More...
 
template<typename Type >
lookup_result_type< Type > lookup (const pmInDom indom, const std::string &name, const std::string &key, const lookup_flags flags=require_active)
 Lookup a cache entry, by instance name and key. More...
 
int perform (const pmInDom indom, const int operation)
 Perform additional operations on the cache. More...
 
size_t purge (const pmInDom indom, const time_t recent)
 Purge cache entries that have not been active for some time. More...
 
size_t purge (const pmInDom indom, const boost::posix_time::time_duration &recent)
 Purge cache entries that have not been active for some time. More...
 
instance_id_type store (const pmInDom indom, const std::string &name, const int flags=PMDA_CACHE_ADD, void *const opaque=NULL)
 Add a item to the cache. More...
 
instance_id_type store (const pmInDom indom, const std::string &name, void *const opaque, const int flags=PMDA_CACHE_ADD)
 Add a item to the cache. More...
 
instance_id_type store (const pmInDom indom, const std::string &name, const std::string &key, const int flags=0, void *const opaque=NULL)
 Add a item to the cache. More...
 
instance_id_type store (const pmInDom indom, const std::string &name, const std::string &key, void *const opaque, const int flags=0)
 Add a item to the cache. More...
 

Enumeration Type Documentation

◆ lookup_flags

Flags that may be applied to cache lookups.

Enumerator
require_active 

Throw if the found cache entry is not active.

Definition at line 28 of file cache.hpp.

Function Documentation

◆ lookup() [1/3]

template<typename Type >
lookup_result_type<Type> pcp::cache::lookup ( const pmInDom  indom,
const instance_id_type  instance_id,
const lookup_flags  flags = require_active 
)

Lookup a cache entry, by instance ID.

If flags includes require_active, and an inactive cache entry is found, a pcp::exception will be thrown instead of the inactive entry returned.

Template Parameters
TypeType to cast opaque pointers to.
Parameters
indomInstance domain to lookup.
instance_idInstance ID to lookup.
flagsOptional flags that alter the function's behaviour.
Exceptions
pcp::exceptionIf no cache entry entry found.
Returns
A struct containing the found cache entry details.
See also
pmdaCacheLookup

Definition at line 83 of file cache.hpp.

References pcp::cache::lookup_result_type< Type >::instance_id, pcp::cache::lookup_result_type< Type >::name, pcp::cache::lookup_result_type< Type >::opaque, require_active, and pcp::cache::lookup_result_type< Type >::status.

◆ lookup() [2/3]

template<typename Type >
lookup_result_type<Type> pcp::cache::lookup ( const pmInDom  indom,
const std::string &  name,
const lookup_flags  flags = require_active 
)

Lookup a cache entry, by instance name.

If flags includes require_active, and an inactive cache entry is found, a pcp::exception will be thrown instead of the inactive entry returned.

Template Parameters
TypeType to cast opaque pointers to.
Parameters
indomInstance domain to lookup.
nameInstance name to lookup.
flagsOptional flags that alter the function's behaviour.
Exceptions
pcp::exceptionIf no cache entry entry found.
Returns
A struct containing the found cache entry details.
See also
pmdaCacheLookupName

Definition at line 129 of file cache.hpp.

References pcp::cache::lookup_result_type< Type >::instance_id, pcp::cache::lookup_result_type< Type >::name, pcp::cache::lookup_result_type< Type >::opaque, require_active, and pcp::cache::lookup_result_type< Type >::status.

◆ lookup() [3/3]

template<typename Type >
lookup_result_type<Type> pcp::cache::lookup ( const pmInDom  indom,
const std::string &  name,
const std::string &  key,
const lookup_flags  flags = require_active 
)

Lookup a cache entry, by instance name and key.

If flags includes require_active, and an inactive cache entry is found, a pcp::exception will be thrown instead of the inactive entry returned.

Template Parameters
TypeType to cast opaque pointers to.
Parameters
indomInstance domain to lookup.
nameInstance name to lookup.
keyInstance key to lookup.
flagsOptional flags that alter the function's behaviour.
Exceptions
pcp::exceptionIf no cache entry entry found.
Returns
A struct containing the found cache entry details.
See also
pmdaCacheLookupKey

Definition at line 171 of file cache.hpp.

References pcp::cache::lookup_result_type< Type >::instance_id, pcp::cache::lookup_result_type< Type >::name, pcp::cache::lookup_result_type< Type >::opaque, require_active, and pcp::cache::lookup_result_type< Type >::status.

◆ operator|()

lookup_flags pcp::cache::operator| ( lookup_flags  a,
lookup_flags  b 
)
inline

Pipe operator for combining lookup_flags values.

This function performs a logical OR of two lookup_flags sets. This is a convenience function, allowing lookup_flags enum values to be used both standalone, and in combination.

Parameters
aFirst set of flags.
bSecond set of flags.
Returns
Combined set of both a and b flags.

Definition at line 44 of file cache.hpp.

◆ perform()

int pcp::cache::perform ( const pmInDom  indom,
const int  operation 
)
inline

Perform additional operations on the cache.

This is a very simple wrapper for PCP's pmdaCacheOp function.

Parameters
indomInstance domain to operate on.
operationOperation to perform. Should be one of the PMDA_CACHE_* constants.
Exceptions
pcp::exceptionOn errors.
Returns
The result of the pmdaCacheOp function. See pmdaCacheOp for details.
See also
pmdaCacheOp

Definition at line 210 of file cache.hpp.

◆ purge() [1/2]

size_t pcp::cache::purge ( const pmInDom  indom,
const time_t  recent 
)
inline

Purge cache entries that have not been active for some time.

Parameters
indomInstance domain to purge entries for.
recentAll entries that have not been active within this many seconds will be purged.
Exceptions
pcp::exceptionOn error.
Returns
The number of items purged.
See also
pmdaCachePurge

Definition at line 232 of file cache.hpp.

Referenced by purge().

◆ purge() [2/2]

size_t pcp::cache::purge ( const pmInDom  indom,
const boost::posix_time::time_duration &  recent 
)
inline

Purge cache entries that have not been active for some time.

Parameters
indomInstance domain to purge entries for.
recentAll entries that have not been active within this interval will be purged.
Exceptions
pcp::exceptionOn error.
Returns
The number of items purged.
See also
pmdaCachePurge

Definition at line 255 of file cache.hpp.

References purge().

◆ store() [1/4]

instance_id_type pcp::cache::store ( const pmInDom  indom,
const std::string &  name,
const int  flags = PMDA_CACHE_ADD,
void *const  opaque = NULL 
)
inline

Add a item to the cache.

Parameters
indomInstance domain to add an entry for.
nameInstance name to add to the cache.
flagsOptional flags to be passed to pmdaCacheStore.
opaqueOptional opaque pointer to be include in the cache entry.
Exceptions
pcp::exceptionOn error.
Returns
The instance ID of the stored cache entry.
See also
pmdaCacheStore

Definition at line 275 of file cache.hpp.

References pcp::cache::lookup_result_type< Type >::opaque.

Referenced by pcp::pmda::parse_command_line().

◆ store() [2/4]

instance_id_type pcp::cache::store ( const pmInDom  indom,
const std::string &  name,
void *const  opaque,
const int  flags = PMDA_CACHE_ADD 
)
inline

Add a item to the cache.

Parameters
indomInstance domain to add an entry for.
nameInstance name to add to the cache.
opaqueOptional opaque pointer to be include in the cache entry.
flagsOptional flags to be passed to pmdaCacheStore.
Exceptions
pcp::exceptionOn error.
Returns
The instance ID of the stored cache entry.
See also
pmdaCacheStore

Definition at line 300 of file cache.hpp.

References pcp::cache::lookup_result_type< Type >::opaque.

◆ store() [3/4]

instance_id_type pcp::cache::store ( const pmInDom  indom,
const std::string &  name,
const std::string &  key,
const int  flags = 0,
void *const  opaque = NULL 
)
inline

Add a item to the cache.

Parameters
indomInstance domain to add an entry for.
keyHint to pass to pmdaCacheStoreKey. See pmdaCacheStoreKey for details.
nameInstance name to add to the cache.
flagsOptional flags to be passed to pmdaCacheStore.
opaqueOptional opaque pointer to be include in the cache entry.
Exceptions
pcp::exceptionOn error.
Returns
The instance ID of the stored cache entry.
See also
pmdaCacheStoreKey

Definition at line 326 of file cache.hpp.

References pcp::cache::lookup_result_type< Type >::opaque.

◆ store() [4/4]

instance_id_type pcp::cache::store ( const pmInDom  indom,
const std::string &  name,
const std::string &  key,
void *const  opaque,
const int  flags = 0 
)
inline

Add a item to the cache.

Parameters
indomInstance domain to add an entry for.
keyHint to pass to pmdaCacheStoreKey. See pmdaCacheStoreKey for details.
nameInstance name to add to the cache.
opaqueOptional opaque pointer to be include in the cache entry.
flagsOptional flags to be passed to pmdaCacheStore.
Exceptions
pcp::exceptionOn error.
Returns
The instance ID of the stored cache entry.
See also
pmdaCacheStoreKey

Definition at line 354 of file cache.hpp.

References pcp::cache::lookup_result_type< Type >::opaque.