D++ (DPP)  10.0.30
C++ Discord API Bot Library
cache.cpp File Reference
#include <dpp/export.h>
#include <mutex>
#include <iostream>
#include <variant>
#include <dpp/cache.h>
#include <dpp/exception.h>
Include dependency graph for cache.cpp:

Namespaces

 dpp
 The main namespace for D++ functions.
 

Macros

#define cache_helper(type, cache_name, setter, getter, counter)
 

Functions

DPP_EXPORT class channel * dpp::find_channel (snowflake id)
 Find an object in the cache by id. More...
 
DPP_EXPORT class emoji * dpp::find_emoji (snowflake id)
 Find an object in the cache by id. More...
 
DPP_EXPORT class guild * dpp::find_guild (snowflake id)
 Find an object in the cache by id. More...
 
DPP_EXPORT class role * dpp::find_role (snowflake id)
 Find an object in the cache by id. More...
 
DPP_EXPORT class user * dpp::find_user (snowflake id)
 Find an object in the cache by id. More...
 
void DPP_EXPORT dpp::garbage_collection ()
 Run garbage collection across all caches removing deleted items that have been deleted over 60 seconds ago. More...
 
DPP_EXPORT cache< class channel > * dpp::get_channel_cache ()
 
DPP_EXPORT uint64_t dpp::get_channel_count ()
 Get the amount of cached channel objects. More...
 
DPP_EXPORT cache< class emoji > * dpp::get_emoji_cache ()
 
DPP_EXPORT uint64_t dpp::get_emoji_count ()
 Get the amount of cached emoji objects. More...
 
DPP_EXPORT cache< class guild > * dpp::get_guild_cache ()
 
DPP_EXPORT uint64_t dpp::get_guild_count ()
 Get the amount of cached guild objects. More...
 
DPP_EXPORT cache< class role > * dpp::get_role_cache ()
 
DPP_EXPORT uint64_t dpp::get_role_count ()
 Get the amount of cached role objects. More...
 
DPP_EXPORT cache< class user > * dpp::get_user_cache ()
 
DPP_EXPORT uint64_t dpp::get_user_count ()
 Get the amount of cached user objects. More...
 

Variables

cache< channel > * dpp::channel_cache = nullptr
 
cache< emoji > * dpp::emoji_cache = nullptr
 
cache< guild > * dpp::guild_cache = nullptr
 
cache< role > * dpp::role_cache = nullptr
 
cache< user > * dpp::user_cache = nullptr
 

Macro Definition Documentation

◆ cache_helper

#define cache_helper (   type,
  cache_name,
  setter,
  getter,
  counter 
)
Value:
cache<type>* cache_name = nullptr; \
type * setter (snowflake id) { \
return cache_name ? ( type * ) cache_name ->find(id) : nullptr; \
} \
cache<type>* getter () { \
if (! cache_name ) { \
cache_name = new cache<type>(); \
} \
return cache_name ; \
} \
uint64_t counter () { \
return ( cache_name ? cache_name ->count() : 0 ); \
}
dpp::unicode_emoji::snowflake
constexpr const char snowflake[]
Definition: unicode_emoji.h:1290