mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-08 00:14:31 +08:00
Memorize query results in blog service (#8374)
The query for all published blogs is being called twice while building the admin menu, so we are memorizing its results.
This commit is contained in:

committed by
GitHub

parent
9392718d3e
commit
f581d235d2
@@ -51,8 +51,14 @@ namespace Orchard.Blogs.Services {
|
||||
return blogPart == null ? null : blogPart.ContentItem;
|
||||
}
|
||||
|
||||
private IEnumerable<BlogPart> _publishedBlogs;
|
||||
public IEnumerable<BlogPart> Get() {
|
||||
return Get(VersionOptions.Published);
|
||||
// this is currently called at least twice per request on the
|
||||
// back-office, both times by the code building the admin menu.
|
||||
if (_publishedBlogs == null) {
|
||||
_publishedBlogs = Get(VersionOptions.Published);
|
||||
}
|
||||
return _publishedBlogs;
|
||||
}
|
||||
|
||||
public IEnumerable<BlogPart> Get(VersionOptions versionOptions) {
|
||||
|
Reference in New Issue
Block a user