D++ (DPP)
C++ Discord API Bot Library
dpp::cache Class Reference

A cache object maintains a cache of dpp::managed objects. This is for example users, channels or guilds. More...

#include <cache.h>

Public Member Functions

 cache ()
 Construct a new cache object. More...
 
 ~cache ()
 Destroy the cache object. More...
 
void store (managed *object)
 
void remove (managed *object)
 
managedfind (snowflake id)
 
uint64_t count ()
 
std::mutex & get_mutex ()
 Return the cache's locking mutex. Use this whenever you manipulate or iterate raw elements in the cache! More...
 
cache_containerget_container ()
 Get the container map. More...
 
void rehash ()
 "Rehash" a cache by cleaning out used RAM More...
 
size_t bytes ()
 Get "real" size in RAM of the cache. More...
 

Detailed Description

A cache object maintains a cache of dpp::managed objects. This is for example users, channels or guilds.

Constructor & Destructor Documentation

◆ cache()

dpp::cache::cache ( )

Construct a new cache object.

◆ ~cache()

dpp::cache::~cache ( )

Destroy the cache object.

Member Function Documentation

◆ bytes()

size_t dpp::cache::bytes ( )

Get "real" size in RAM of the cache.

Returns
size_t

◆ count()

uint64_t dpp::cache::count ( )

Return a count of the number of items in the cache.

◆ find()

managed * dpp::cache::find ( snowflake  id)

Find an object in the cache by id.

Parameters
idObject id to find

◆ get_container()

cache_container & dpp::cache::get_container ( )

Get the container map.

Warning
Be sure to use cache::get_mutex() correctly if you manipulate or iterate the map returned by this method! If you do not, this is not thread safe and will cause crashes!
See also
cache::get_mutex
Returns
cache_container& A reference to the cache's container map

◆ get_mutex()

std::mutex & dpp::cache::get_mutex ( )

Return the cache's locking mutex. Use this whenever you manipulate or iterate raw elements in the cache!

Returns
The mutex used to protect the container

◆ rehash()

void dpp::cache::rehash ( )

"Rehash" a cache by cleaning out used RAM

Warning
May be time consuming!

◆ remove()

void dpp::cache::remove ( managed object)

Remove an object from the cache.

Parameters
objectobject to remove

◆ store()

void dpp::cache::store ( managed object)

Store an object in the cache.

Parameters
objectobject to store
D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0