So we have a WCF service that provides some object to the client. Our wcf service gets the data from a Data Access Layer (DAL). The DAL gets the data from an API and formats it into an object that we can use. For the most of the objects this works well.
But we also need a list of objects from the API and the objects don't change. The query against the API takes up 15 to 20 seconds. Way to long to run this query multiple times for the same data. So we would like to store the list in memory. Because the DBA's are not our best friends, and SQLite or SQL CE is not an option.
Now we have something like this, the first time the groups are loaded we store them in a private static variable. Is this the right way to do something like this, or is there a better way?
public static class GroupStore
{
private static DTO.Group[] _groups;
public static DTO.Group[] GetAll()
{
if (_groups == null)
{
var dal = PluginHandler.Instance.GetPlugin();
_groups = dal.GetAll();
}
return _groups;
}
}