--------------------------------------------------------------------------------
Hello everyone,
I am going to design a Cache in C/C++ (memory cache). I have two different approaches to design/implement it, any comments will be appreciated.
Design 1, using a map (hashtable) to store key --> object pointer relationship (simple and straight forward);
Design 2, store real object or object pointer in a stack/linked list/queue/array as an internal storage data structure, then using a map (hashtable) as an external interface to mapping key --> index in the stack/linked list/queue/array; (in this design, when accessing an object, we need two times mapping, first mapping key to index in the stack/linked list/queue/array, then using the index to access the real object)
I am wondering any advantages or disadvantages of the two designs. Any better design approach suggestion will be appreciated.
thanks in advance,
George