Florian Zschocke
2013-07-09 a0c34e37fe8e456a21c7a57e9d45e637ab40cce8
src/main/java/com/gitblit/utils/CommitCache.java
@@ -67,7 +67,7 @@
    * 
    * @return
    */
   protected Date getCacheCutoffDate() {
   public Date getCutoffDate() {
      final Calendar cal = Calendar.getInstance();
      cal.setTimeInMillis(System.currentTimeMillis());
      cal.set(Calendar.HOUR_OF_DAY, 0);
@@ -110,6 +110,23 @@
   }
   
   /**
    * Clears the commit cache for a specific branch of a specific repository.
    *
    * @param repositoryName
    * @param branch
    */
   public void clear(String repositoryName, String branch) {
      String repoKey = repositoryName.toLowerCase();
      ObjectCache<List<RepositoryCommit>> repoCache = cache.get(repoKey);
      if (repoCache != null) {
         List<RepositoryCommit> commits = repoCache.remove(branch.toLowerCase());
         if (!ArrayUtils.isEmpty(commits)) {
            logger.info(MessageFormat.format("{0}:{1} commit cache cleared", repositoryName, branch));
         }
      }
   }
   /**
    * Get all commits for the specified repository:branch that are in the cache.
    * 
    * @param repositoryName
@@ -118,7 +135,7 @@
    * @return a list of commits
    */
   public List<RepositoryCommit> getCommits(String repositoryName, Repository repository, String branch) {
      return getCommits(repositoryName, repository, branch, getCacheCutoffDate());
      return getCommits(repositoryName, repository, branch, getCutoffDate());
   }
   
   /**
@@ -134,7 +151,7 @@
    */
   public List<RepositoryCommit> getCommits(String repositoryName, Repository repository, String branch, Date sinceDate) {
      long start = System.nanoTime();
      Date cacheCutoffDate = getCacheCutoffDate();
      Date cacheCutoffDate = getCutoffDate();
      List<RepositoryCommit> list;
      if (cacheDays > 0 && (sinceDate.getTime() >= cacheCutoffDate.getTime())) {
         // request fits within the cache window