Cache manager class

I need to cache some png and svg images generated by latex in order to avoid parsing many times the same string. I currently do that using global std::map variable but I am at the point where I’d like to move this to some proper/safe place.

Should I follow e.g. the example of the ft_manager which IIUC follows the singleton pattern or do you have some other recommendations? Better, do we have some example of a singleton cache manager class, that can eventually use a FIFO buffer when the cache becomes too large (e.g. after long sessions)? Oh, and if the access to data could be thread safe it would be even better. I know, this looks like a letter to Santa Claus and a french would answer “et tu veux pas cent balles et un mars?” but we never know :slight_smile: .

I believe @jwe has negative opinions about the singleton style of programming. He can chime in here.

Yeah, I would rather avoid them now as they are just another kind of global data and I’m trying as much as possible to eliminate global data.

What objects need access to this cache of images? Who is the logical owner of that data?

Currently, only latext_text_renderer objects which are owned by generic text_renderer objects, which in turn are owned by graphics_objects (text and axes) and opengl_renderer objects.

The first that come to my mind is the gh_manager.