LruMap< Key, EntryValue, EntryCost > Class Template Reference

#include <LruMap.h>

Collaboration diagram for LruMap< Key, EntryValue, EntryCost >:

Classes

class  Entry
 

Public Types

typedef std::list< Entry * > Queue
 
typedef std::list< Entry * >
::iterator 
QueueIterator
 
typedef std::map< Key,
QueueIterator
Map
 key:queue_item mapping for fast lookups by key More...
 
typedef Map::iterator MapIterator
 
typedef std::pair< Key,
QueueIterator
MapPair
 

Public Member Functions

 LruMap (int ttl, size_t size)
 
 ~LruMap ()
 
EntryValue * get (const Key &key)
 Search for an entry, and return a pointer. More...
 
bool add (const Key &key, EntryValue *t)
 Add an entry to the map. More...
 
bool del (const Key &key)
 Delete an entry from the map. More...
 
void setMemLimit (size_t aSize)
 (Re-)set the maximum size for this map More...
 
size_t memLimit () const
 The available size for the map. More...
 
size_t freeMem () const
 The free space of the map. More...
 
size_t size () const
 The current size of the map. More...
 
int entries () const
 The number of stored entries. More...
 

Private Member Functions

 LruMap (LruMap const &)
 
LruMapoperator= (LruMap const &)
 
bool expired (const Entry &e) const
 
void trim ()
 
void touch (const MapIterator &i)
 
bool del (const MapIterator &i)
 
void findEntry (const Key &key, LruMap::MapIterator &i)
 

Private Attributes

Map storage
 The Key/value * pairs. More...
 
Queue index
 LRU cache index. More...
 
int ttl
 >0 ttl for caching, == 0 cache is disabled, < 0 store for ever More...
 
size_t memLimit_
 The maximum memory to use. More...
 
int entries_
 The stored entries. More...
 

Detailed Description

template<class Key, class EntryValue, size_t EntryCost = sizeof(EntryValue)>
class LruMap< Key, EntryValue, EntryCost >

Definition at line 17 of file LruMap.h.

Member Typedef Documentation

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
typedef std::map<Key, QueueIterator> LruMap< Key, EntryValue, EntryCost >::Map

Definition at line 37 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
typedef Map::iterator LruMap< Key, EntryValue, EntryCost >::MapIterator

Definition at line 38 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
typedef std::pair<Key, QueueIterator> LruMap< Key, EntryValue, EntryCost >::MapPair

Definition at line 39 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
typedef std::list<Entry *> LruMap< Key, EntryValue, EntryCost >::Queue

Definition at line 33 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
typedef std::list<Entry *>::iterator LruMap< Key, EntryValue, EntryCost >::QueueIterator

Definition at line 34 of file LruMap.h.

Constructor & Destructor Documentation

template<class Key , class EntryValue , size_t EntryCost>
LruMap< Key, EntryValue, EntryCost >::LruMap ( int  ttl,
size_t  size 
)
template<class Key , class EntryValue , size_t EntryCost>
LruMap< Key, EntryValue, EntryCost >::~LruMap ( )

Definition at line 85 of file LruMap.h.

References i.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
LruMap< Key, EntryValue, EntryCost >::LruMap ( LruMap< Key, EntryValue, EntryCost > const &  )
private

Member Function Documentation

template<class Key , class EntryValue , size_t EntryCost>
bool LruMap< Key, EntryValue, EntryCost >::add ( const Key &  key,
EntryValue *  t 
)

Definition at line 140 of file LruMap.h.

References trim().

Referenced by ConnStateData::storeTlsContextToCache().

template<class Key , class EntryValue , size_t EntryCost>
bool LruMap< Key, EntryValue, EntryCost >::del ( const Key &  key)

Definition at line 185 of file LruMap.h.

References i.

Referenced by ConnStateData::getTlsContextFromCache().

template<class Key , class EntryValue , size_t EntryCost>
bool LruMap< Key, EntryValue, EntryCost >::del ( const MapIterator i)
private

Definition at line 170 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
int LruMap< Key, EntryValue, EntryCost >::entries ( ) const
inline
template<class Key , class EntryValue , size_t EntryCost>
bool LruMap< Key, EntryValue, EntryCost >::expired ( const Entry e) const
private

Definition at line 160 of file LruMap.h.

References LruMap< Key, EntryValue, EntryCost >::Entry::date, and squid_curtime.

template<class Key , class EntryValue , size_t EntryCost>
void LruMap< Key, EntryValue, EntryCost >::findEntry ( const Key &  key,
LruMap< Key, EntryValue, EntryCost >::MapIterator i 
)
private

Definition at line 104 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
size_t LruMap< Key, EntryValue, EntryCost >::freeMem ( ) const
inline
template<class Key , class EntryValue , size_t EntryCost>
EntryValue * LruMap< Key, EntryValue, EntryCost >::get ( const Key &  key)
template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
size_t LruMap< Key, EntryValue, EntryCost >::memLimit ( ) const
inline
template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
LruMap& LruMap< Key, EntryValue, EntryCost >::operator= ( LruMap< Key, EntryValue, EntryCost > const &  )
private
template<class Key , class EntryValue , size_t EntryCost>
void LruMap< Key, EntryValue, EntryCost >::setMemLimit ( size_t  aSize)

Definition at line 94 of file LruMap.h.

Referenced by LruMap< Key, EntryValue, EntryCost >::LruMap().

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
size_t LruMap< Key, EntryValue, EntryCost >::size ( ) const
inline
template<class Key , class EntryValue , size_t EntryCost>
void LruMap< Key, EntryValue, EntryCost >::touch ( const MapIterator i)
private

Definition at line 207 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost>
void LruMap< Key, EntryValue, EntryCost >::trim ( )
private

Definition at line 194 of file LruMap.h.

References i, and size.

Member Data Documentation

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
int LruMap< Key, EntryValue, EntryCost >::entries_
private
template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
Queue LruMap< Key, EntryValue, EntryCost >::index
private

Definition at line 70 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
size_t LruMap< Key, EntryValue, EntryCost >::memLimit_
private

Definition at line 72 of file LruMap.h.

Referenced by LruMap< Key, EntryValue, EntryCost >::memLimit().

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
Map LruMap< Key, EntryValue, EntryCost >::storage
private

Definition at line 69 of file LruMap.h.

template<class Key , class EntryValue , size_t EntryCost = sizeof(EntryValue)>
int LruMap< Key, EntryValue, EntryCost >::ttl
private

Definition at line 71 of file LruMap.h.

Referenced by LruMap< Key, EntryValue, EntryCost >::LruMap().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors