Skip to content

Commit d72f133

Browse files
committed
Workaround for GH-139: Content items cache issues on DNN 9
1 parent 05db0cb commit d72f133

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Diff for: R7.News/Data/NewsRepository.cs

+14-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public int AddNewsEntry (NewsEntry newsEntry,
6565
UpdateNewsEntryText (newsEntry);
6666
UpdateContentItem (contentItem, newsEntry, terms, images);
6767

68-
ClearCache ();
68+
ClearCache (newsEntry);
6969

7070
return newsEntry.EntryId;
7171
}
@@ -185,7 +185,7 @@ public void UpdateNewsEntry (NewsEntry newsEntry, List<Term> terms, int moduleId
185185
termController.AddTermToContent (term, newsEntry.ContentItem);
186186
}
187187

188-
ClearCache ();
188+
ClearCache (newsEntry);
189189
}
190190

191191
/// <summary>
@@ -196,15 +196,15 @@ public void UpdateNewsEntry (NewsEntry newsEntry)
196196
{
197197
NewsDataProvider.Instance.Update (newsEntry);
198198

199-
ClearCache ();
199+
ClearCache (newsEntry);
200200
}
201201

202202
public void DeleteNewsEntry (INewsEntry newsEntry)
203203
{
204204
// delete content item, related news entry and text records will be deleted by foreign key rules
205205
NewsDataProvider.Instance.ContentController.DeleteContentItem (newsEntry.ContentItem);
206206

207-
ClearCache ();
207+
ClearCache (newsEntry);
208208
}
209209

210210
public IEnumerable<NewsEntry> GetAllNewsEntries (int moduleId,
@@ -383,8 +383,17 @@ public void ClearModuleCache (int moduleId, int tabModuleId)
383383
DataCache.ClearCache (NewsCacheKeyPrefix + "ModuleId=" + moduleId);
384384
}
385385

386-
public void ClearCache ()
386+
// Workaround for GH-139: Content items cache issues on DNN 9
387+
private void ClearContentItemCache (int? contentItemId)
387388
{
389+
if (contentItemId != null) {
390+
DataCache.RemoveCache ($"ContentItems{contentItemId}");
391+
}
392+
}
393+
394+
private void ClearCache (INewsEntry newsEntry)
395+
{
396+
ClearContentItemCache (newsEntry.ContentItemId);
388397
DataCache.ClearCache (NewsCacheKeyPrefix);
389398
}
390399
}

0 commit comments

Comments
 (0)