cache algorithm c++