blob: 26d450012696e6c3f773b0a3bc79ed6e4fc4a7b2 [file] [log] [blame]
LRU Design
==========
This got slightly complex, because I tried to be clever. But the concept is easy, a
list and an unordered map keeps the LRU state.
+-----------------------+ +----------------------------------+
| LRUList | | LRUMap |
| ------- | | ------ |
|+---------------------+| |+--------------------------------+|
+---------------------+ +---------------------+ || LRUEntry <+----+| {LRUHash *, LRUList::iterator} ||
| LRUHash | | LRUEntry | |+---------------------+| |+--------------------------------+|
| -------- |<--+ -------- |<--+| LRUEntry <+----+| {LRUHash *, LRUList::iterator} ||
| u_char _hash[20] | | <LRUHash, unsigned> | |+---------------------+| |+--------------------------------+|
+---------------------+ +---------------------+ || LRUEntry <+----+| {LRUHash *, LRUList::iterator} ||
+-----------------+ |+---------------------+| |+--------------------------------+|
| first = LRUHash | | | | |
|second = unsigned| | * | | * |
+-----------------+ | * | | * |
| * | | * |
| | | |
|+---------------------+| |+--------------------------------+|
|| LRUEntry || || {LRUHash *, LRUList::iterator} ||
|+---------------------+| |+--------------------------------+|
+-----------------------+ +----------------------------------+
+--------------------------+
| first = LRUHash* |
|second = LRUList::iterator|
+--------------------------+