diff options
author | James Moger <james.moger@gitblit.com> | 2013-01-03 17:22:21 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-01-03 17:22:21 -0500 |
commit | eee533b4583854b9c875221f1c1f50dfb092868d (patch) | |
tree | 8b3c9fb798e45647138b0b93c91d3e6ef743d336 /src/com/gitblit/GitBlit.java | |
parent | 7ec9d3d1b460db339db2770f3aa81af9826deed3 (diff) | |
download | gitblit-eee533b4583854b9c875221f1c1f50dfb092868d.tar.gz gitblit-eee533b4583854b9c875221f1c1f50dfb092868d.zip |
Cache and re-use project markdown content (issue-172)
Diffstat (limited to 'src/com/gitblit/GitBlit.java')
-rw-r--r-- | src/com/gitblit/GitBlit.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 96333a07..30071bb6 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -154,6 +154,10 @@ public class GitBlit implements ServletContextListener { private final Map<String, ProjectModel> projectCache = new ConcurrentHashMap<String, ProjectModel>();
private final AtomicReference<String> repositoryListSettingsChecksum = new AtomicReference<String>("");
+
+ private final ObjectCache<String> projectMarkdownCache = new ObjectCache<String>();
+
+ private final ObjectCache<String> projectRepositoriesMarkdownCache = new ObjectCache<String>();
private ServletContext servletContext;
@@ -1402,7 +1406,30 @@ public class GitBlit implements ServletContextListener { }
project.title = projectConfigs.getString("project", name, "title");
project.description = projectConfigs.getString("project", name, "description");
- configs.put(name.toLowerCase(), project);
+
+ // project markdown
+ File pmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : name) + "/project.mkd");
+ if (pmkd.exists()) {
+ Date lm = new Date(pmkd.lastModified());
+ if (!projectMarkdownCache.hasCurrent(name, lm)) {
+ String mkd = com.gitblit.utils.FileUtils.readContent(pmkd, "\n");
+ projectMarkdownCache.updateObject(name, lm, mkd);
+ }
+ project.projectMarkdown = projectMarkdownCache.getObject(name);
+ }
+
+ // project repositories markdown
+ File rmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : name) + "/repositories.mkd");
+ if (rmkd.exists()) {
+ Date lm = new Date(rmkd.lastModified());
+ if (!projectRepositoriesMarkdownCache.hasCurrent(name, lm)) {
+ String mkd = com.gitblit.utils.FileUtils.readContent(rmkd, "\n");
+ projectRepositoriesMarkdownCache.updateObject(name, lm, mkd);
+ }
+ project.repositoriesMarkdown = projectRepositoriesMarkdownCache.getObject(name);
+ }
+
+ configs.put(name.toLowerCase(), project);
}
projectCache.clear();
projectCache.putAll(configs);
|