diff options
author | James Moger <james.moger@gitblit.com> | 2013-09-30 09:30:04 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-09-30 10:11:28 -0400 |
commit | 699e71e76b15081baf746c6ce9c9144f7e5f1ff9 (patch) | |
tree | 4a9ea25c258caeae3dea4bc1de809f47bc615d81 /src/main/java/com/gitblit/utils/CommitCache.java | |
parent | 235ad956fa84cad4fac1b2e69a0c9e4f50376ea3 (diff) | |
download | gitblit-699e71e76b15081baf746c6ce9c9144f7e5f1ff9.tar.gz gitblit-699e71e76b15081baf746c6ce9c9144f7e5f1ff9.zip |
Trim trailing whitespace and organize imports
Change-Id: I9f91138b20219be6e3c4b28251487df262bff6cc
Diffstat (limited to 'src/main/java/com/gitblit/utils/CommitCache.java')
-rw-r--r-- | src/main/java/com/gitblit/utils/CommitCache.java | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/main/java/com/gitblit/utils/CommitCache.java b/src/main/java/com/gitblit/utils/CommitCache.java index e84506ea..fd3a6597 100644 --- a/src/main/java/com/gitblit/utils/CommitCache.java +++ b/src/main/java/com/gitblit/utils/CommitCache.java @@ -35,36 +35,36 @@ import com.gitblit.models.RepositoryCommit; /** * Caches repository commits for re-use in the dashboard and activity pages. - * + * * @author James Moger * */ public class CommitCache { - + private static final CommitCache instance; - + protected final Logger logger = LoggerFactory.getLogger(getClass()); - + protected final Map<String, ObjectCache<List<RepositoryCommit>>> cache; - + protected int cacheDays = -1; - + public static CommitCache instance() { return instance; } - + static { instance = new CommitCache(); } - + protected CommitCache() { cache = new ConcurrentHashMap<String, ObjectCache<List<RepositoryCommit>>>(); } - + /** * Returns the cutoff date for the cache. Commits after this date are cached. * Commits before this date are not cached. - * + * * @return */ public Date getCutoffDate() { @@ -77,28 +77,28 @@ public class CommitCache { cal.add(Calendar.DATE, -1*cacheDays); return cal.getTime(); } - + /** * Sets the number of days to cache. - * + * * @param days */ public synchronized void setCacheDays(int days) { this.cacheDays = days; clear(); } - + /** * Clears the entire commit cache. - * + * */ public void clear() { cache.clear(); } - + /** * Clears the commit cache for a specific repository. - * + * * @param repositoryName */ public void clear(String repositoryName) { @@ -108,10 +108,10 @@ public class CommitCache { logger.info(MessageFormat.format("{0} commit cache cleared", repositoryName)); } } - + /** * Clears the commit cache for a specific branch of a specific repository. - * + * * @param repositoryName * @param branch */ @@ -125,10 +125,10 @@ public class CommitCache { } } } - + /** * Get all commits for the specified repository:branch that are in the cache. - * + * * @param repositoryName * @param repository * @param branch @@ -137,12 +137,12 @@ public class CommitCache { public List<RepositoryCommit> getCommits(String repositoryName, Repository repository, String branch) { return getCommits(repositoryName, repository, branch, getCutoffDate()); } - + /** * Get all commits for the specified repository:branch since a specific date. * These commits may be retrieved from the cache if the sinceDate is after * the cacheCutoffDate. - * + * * @param repositoryName * @param repository * @param branch @@ -159,13 +159,13 @@ public class CommitCache { if (!cache.containsKey(repoKey)) { cache.put(repoKey, new ObjectCache<List<RepositoryCommit>>()); } - + ObjectCache<List<RepositoryCommit>> repoCache = cache.get(repoKey); String branchKey = branch.toLowerCase(); - + RevCommit tip = JGitUtils.getCommit(repository, branch); Date tipDate = JGitUtils.getCommitDate(tip); - + List<RepositoryCommit> commits; if (!repoCache.hasCurrent(branchKey, tipDate)) { commits = repoCache.getObject(branchKey); @@ -193,7 +193,7 @@ public class CommitCache { // update cache repoCache.updateObject(branchKey, tipDate, commits); } - + if (sinceDate.equals(cacheCutoffDate)) { list = commits; } else { @@ -210,10 +210,10 @@ public class CommitCache { } return list; } - + /** - * Returns a list of commits for the specified repository branch. - * + * Returns a list of commits for the specified repository branch. + * * @param repositoryName * @param repository * @param branch @@ -230,10 +230,10 @@ public class CommitCache { } return commits; } - + /** - * Returns a list of commits for the specified repository branch since the specified commit. - * + * Returns a list of commits for the specified repository branch since the specified commit. + * * @param repositoryName * @param repository * @param branch @@ -250,10 +250,10 @@ public class CommitCache { } return commits; } - + /** * Reduces the list of commits to those since the specified date. - * + * * @param commits * @param sinceDate * @return a list of commits |