how to implement cache in any module which written in C++

  Kiến thức lập trình

there are two processes/module,suppose p1 and p2 .p1 is doing some calculation and sending result to p2,my question is currently we are saving the result in database and that database is handle by p2 process,so i want to save that result in p2 cache not in database,how to do that?
second issue is if p2 fails during live the and after i restart p2 then i still want that data in cache
both the module/process are written in c++
Note:the calculated value will be different every time and currently it is saving in database according to key like map key value
please help,how can implement this?

i have tried to save the value in map, it got save but after restart or process went down then that map is getting empty

New contributor

Kiran Dhegaskar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.