views:

53

answers:

1

I have to create a COM API which basically will read some data from XML , do some processing on it and return some data as a string.

This API will be in COM DLL which will be in memory most of times.

I have created a struct to hold the data in memory which can be used as cache so as to avoid reading file every time whenever API is called.

I can create a singleton class which can do some processing and store the data in cache.Whenever data changes , it will update the cache and file both.

But this singleton class will only be utilized only when API gets called.This singleton class is not required globally. After reading several articles about singleton , its not a good practice to use singleton just for cache management.

I dont want to go for singleton , but dont have any other solution for this. Any suggestions???

A: 

as far as I understood you want a COM to be reachable from other programs so why don't make COM as "out of process". you will have one instance in memory where you can cache your data.

Arseny