public static MessagesCache GetCache(long groupId, System.Web.Caching.Cache cache) { try { MessagesCache dataObject = (MessagesCache)cache["MessagesCache" + groupId]; if (dataObject == null) { lock (ThisLock) { dataObject = (MessagesCache)cache["MessagesCache" + groupId]; if (dataObject == null) { dataObject = new MessagesCache(); dataObject.GroupIdOfMessages = groupId; dataObject.ListOfRecipients = RDN.Library.Classes.Messages.Messages.GetRecipientsOfMessageGroup(groupId); cache["MessagesCache" + groupId] = dataObject; } } } return dataObject; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return null; }
public static MessagesCache UpdateCache(MessagesCache messageCache, System.Web.Caching.Cache cache) { try { lock (ThisLock) { cache["MessagesCache" + messageCache.GroupIdOfMessages] = messageCache; } return messageCache; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return null; }