mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +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:
@@ -51,8 +51,14 @@ namespace Orchard.Blogs.Services {
|
|||||||
return blogPart == null ? null : blogPart.ContentItem;
|
return blogPart == null ? null : blogPart.ContentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<BlogPart> _publishedBlogs;
|
||||||
public IEnumerable<BlogPart> Get() {
|
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) {
|
public IEnumerable<BlogPart> Get(VersionOptions versionOptions) {
|
||||||
|
|||||||
Reference in New Issue
Block a user