D++ (DPP)  10.0.30
C++ Discord API Bot Library
cache.h File Reference
#include <dpp/export.h>
#include <dpp/snowflake.h>
#include <dpp/managed.h>
#include <unordered_map>
#include <mutex>
#include <shared_mutex>
Include dependency graph for cache.h:
This graph shows which files directly or indirectly include this file:

Classes

class  dpp::cache< T >
 A cache object maintains a cache of dpp::managed objects. More...
 

Namespaces

 dpp
 The main namespace for D++ functions.
 

Macros

#define cache_decl(type, setter, getter, counter)   /** Find an object in the cache by id. @return type* Pointer to the object or nullptr when it's not found */ DPP_EXPORT class type * setter (snowflake id); DPP_EXPORT cache<class type> * getter (); /** Get the amount of cached type objects. */ DPP_EXPORT uint64_t 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

DPP_EXPORT std::mutex dpp::deletion_mutex
 
DPP_EXPORT std::unordered_map< managed *, time_t > dpp::deletion_queue
 

Macro Definition Documentation

◆ cache_decl

#define cache_decl (   type,
  setter,
  getter,
  counter 
)    /** Find an object in the cache by id. @return type* Pointer to the object or nullptr when it's not found */ DPP_EXPORT class type * setter (snowflake id); DPP_EXPORT cache<class type> * getter (); /** Get the amount of cached type objects. */ DPP_EXPORT uint64_t counter ();