|
Covalent Bond
0.0.1-alpha
'covalent bond' is a data middle office. As a 2022-2023 Fall SWE final project.
|
We used LRU alogrithm to implement our cache. More...
#include <cbLRUCache.hpp>

Public Member Functions | |
| cbLRUCache (int32_t max_size) | |
| Construct a new cb Least Recently Use Cache object. More... | |
| ~cbLRUCache () | |
| Destroy the cb Least Recently Use Cache object. More... | |
| void | push (std::string key, V value) |
| Push key and value into cache. If key has been existed, the corresponding value will be update. More... | |
| V * | get (const std::string &key) |
| Get the value of corresponding key of input, if key doesn't exist, it will return null pointer. More... | |
Private Member Functions | |
| void | eraseTail () |
| delete the last element of list More... | |
| void | update (const std::string &key) |
| move the node has been used recently to the top of cache list More... | |
| void | insertTop (const std::string &key) |
| transit the node choosen to the top of list More... | |
| void | __loop_map () |
| loop in cachae list and map More... | |
Private Attributes | |
| int32_t | m_maxSize |
| int32_t | m_sizeCounter |
| node * | m_bufNode |
| std::string | m_bufKey |
| std::list< node > | m_cacheList |
| std::map< std::string, V > | m_cacheMap |
We used LRU alogrithm to implement our cache.
| V | You can set any type of value and key only support string |
Definition at line 39 of file cbLRUCache.hpp.
|
inline |
Construct a new cb Least Recently Use Cache object.
| max_size | Maximum sixe of cache |
Definition at line 46 of file cbLRUCache.hpp.
|
inline |
Destroy the cb Least Recently Use Cache object.
Definition at line 52 of file cbLRUCache.hpp.
References cb::cbLRUCache< V >::m_bufNode.
|
inlineprivate |
loop in cachae list and map
Definition at line 144 of file cbLRUCache.hpp.
References cb::cbLRUCache< V >::m_cacheList, and cb::cbLRUCache< V >::m_cacheMap.
|
inlineprivate |
delete the last element of list
Definition at line 103 of file cbLRUCache.hpp.
References cb::listNode::key, cb::cbLRUCache< V >::m_bufKey, cb::cbLRUCache< V >::m_bufNode, cb::cbLRUCache< V >::m_cacheList, and cb::cbLRUCache< V >::m_cacheMap.
Referenced by cb::cbLRUCache< V >::push().

|
inline |
Get the value of corresponding key of input, if key doesn't exist, it will return null pointer.
| key | key of cache map |
Definition at line 86 of file cbLRUCache.hpp.
References cb::cbLRUCache< V >::m_cacheMap, and cb::cbLRUCache< V >::update().

|
inlineprivate |
transit the node choosen to the top of list
| key | key of cache map |
Definition at line 132 of file cbLRUCache.hpp.
References cb::listNode::key, cb::cbLRUCache< V >::m_bufNode, and cb::cbLRUCache< V >::m_cacheList.
Referenced by cb::cbLRUCache< V >::push(), and cb::cbLRUCache< V >::update().

|
inline |
Push key and value into cache. If key has been existed, the corresponding value will be update.
| key | key of cache map |
| value | value of cache map |
Definition at line 61 of file cbLRUCache.hpp.
References cb::cbLRUCache< V >::eraseTail(), find_list, cb::cbLRUCache< V >::insertTop(), cb::cbLRUCache< V >::m_cacheMap, cb::cbLRUCache< V >::m_maxSize, cb::cbLRUCache< V >::m_sizeCounter, and cb::cbLRUCache< V >::update().

|
inlineprivate |
move the node has been used recently to the top of cache list
| key | key of cache map |
Definition at line 117 of file cbLRUCache.hpp.
References find_list, cb::cbLRUCache< V >::insertTop(), and cb::cbLRUCache< V >::m_cacheList.
Referenced by cb::cbLRUCache< V >::get(), and cb::cbLRUCache< V >::push().


|
private |
Definition at line 158 of file cbLRUCache.hpp.
Referenced by cb::cbLRUCache< V >::eraseTail().
|
private |
Definition at line 157 of file cbLRUCache.hpp.
Referenced by cb::cbLRUCache< V >::eraseTail(), cb::cbLRUCache< V >::insertTop(), and cb::cbLRUCache< V >::~cbLRUCache().
|
private |
Definition at line 159 of file cbLRUCache.hpp.
Referenced by cb::cbLRUCache< V >::__loop_map(), cb::cbLRUCache< V >::eraseTail(), cb::cbLRUCache< V >::insertTop(), and cb::cbLRUCache< V >::update().
|
private |
Definition at line 160 of file cbLRUCache.hpp.
Referenced by cb::cbLRUCache< V >::__loop_map(), cb::cbLRUCache< V >::eraseTail(), cb::cbLRUCache< V >::get(), and cb::cbLRUCache< V >::push().
|
private |
Definition at line 155 of file cbLRUCache.hpp.
Referenced by cb::cbLRUCache< V >::push().
|
private |
Definition at line 156 of file cbLRUCache.hpp.
Referenced by cb::cbLRUCache< V >::push().
1.8.17