Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
aurore::LRUCache< K, T > Class Template Reference

#include <aurore/core/cache_helper.hpp>

Public Types

typedef std::list< Node< K, T > >::iterator CacheIter
 

Public Member Functions

 LRUCache (size_t c, T defaultValue)
 
T get (K key)
 
void set (K key, T value)
 
void setMemoryBudget (size_t bytes, std::function< size_t(T)> sizeOf)
 
size_t getTotalBytes () const
 
size_t getSize () const
 
void remove (T value)
 
void update (T old_val, T new_val)
 
void setCapacity (int c)
 
void markDirty (T value)
 
void markAllDirty ()
 
void trimUnused ()
 
std::list< Node< K, T > > & getCacheList ()
 
void debug ()
 

Static Public Attributes

static size_t DEFAULT_CAPACITY = 400
 
static bool ALWAYS_CACHE_LOCAL_FILE = true
 

Detailed Description

template<typename K, typename T>
class aurore::LRUCache< K, T >

LRU cache If the reference count is not 0, the cache will never expire. Cache items with a reference count of 0 are cached according to LRU rules

Member Typedef Documentation

◆ CacheIter

template<typename K , typename T >
typedef std::list<Node<K,T>>::iterator aurore::LRUCache< K, T >::CacheIter

Constructor & Destructor Documentation

◆ LRUCache()

template<typename K , typename T >
aurore::LRUCache< K, T >::LRUCache ( size_t  c,
T  defaultValue 
)
inline

Member Function Documentation

◆ debug()

template<typename K , typename T >
void aurore::LRUCache< K, T >::debug ( )
inline

◆ get()

template<typename K , typename T >
T aurore::LRUCache< K, T >::get ( K  key)
inline

◆ getCacheList()

template<typename K , typename T >
std::list< Node< K, T > > & aurore::LRUCache< K, T >::getCacheList ( )
inline

◆ getSize()

template<typename K , typename T >
size_t aurore::LRUCache< K, T >::getSize ( ) const
inline

◆ getTotalBytes()

template<typename K , typename T >
size_t aurore::LRUCache< K, T >::getTotalBytes ( ) const
inline

◆ markAllDirty()

template<typename K , typename T >
void aurore::LRUCache< K, T >::markAllDirty ( )
inline

◆ markDirty()

template<typename K , typename T >
void aurore::LRUCache< K, T >::markDirty ( T  value)
inline

A dirty cache is not able to be hit

Parameters
value

◆ remove()

template<typename K , typename T >
void aurore::LRUCache< K, T >::remove ( T  value)
inline

It is not really to remove a cache, but to reduce the counter of the corresponding cache by 1

◆ set()

template<typename K , typename T >
void aurore::LRUCache< K, T >::set ( K  key,
T  value 
)
inline

◆ setCapacity()

template<typename K , typename T >
void aurore::LRUCache< K, T >::setCapacity ( int  c)
inline

◆ setMemoryBudget()

template<typename K , typename T >
void aurore::LRUCache< K, T >::setMemoryBudget ( size_t  bytes,
std::function< size_t(T)>  sizeOf 
)
inline

A budget in bytes, on top of the capacity in entries (0: none). Over it, the least recently used entries nothing holds are freed. sizeOf says what an entry weighs.

◆ trimUnused()

template<typename K , typename T >
void aurore::LRUCache< K, T >::trimUnused ( )
inline

Delete all cache entries whose reference count has dropped to zero. Call this after releasing images to promptly free GPU memory.

◆ update()

template<typename K , typename T >
void aurore::LRUCache< K, T >::update ( T  old_val,
T  new_val 
)
inline

Update a cache value

Member Data Documentation

◆ ALWAYS_CACHE_LOCAL_FILE

template<typename K , typename T >
bool aurore::LRUCache< K, T >::ALWAYS_CACHE_LOCAL_FILE = true
inlinestatic

◆ DEFAULT_CAPACITY

template<typename K , typename T >
size_t aurore::LRUCache< K, T >::DEFAULT_CAPACITY = 400
inlinestatic

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