Fix cache key issue #185

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
@culmat
Contributor

culmat commented May 19, 2014

The cache was not finding any repos with upper case letters in repo name. This fix reduces repo page load time on our installation from > 3 sec to 1.5 sec.

Fix cache key issue
The cache was not finding any repos with upper case letters in repo name. This fix reduces repo page load time on our installation from > 3 sec to 1.5 sec.
@@ -683,7 +683,7 @@ public RepositoryModel getRepositoryModel(String repositoryName) {
repositoryName = repositoryName.replace("%7E", "~").replace("%7e", "~");
if (!repositoryListCache.containsKey(repositoryName)) {

This comment has been minimized.

@gitblit

gitblit May 19, 2014

Owner

We have to be careful when manipulating repository look-ups. The cache lookups should be case-insensitive - but the filesystem lookups are case-sensitive on case-sensitive filesystems.

I think the better fix is to ensure that cache lookups use the proper key, but leave the file system loading as-is. Try the following and let me know if that yields the same time-saving result.

String repositoryKey = repositoryName.toLowerCase();
if (!repositoryListCache.containsKey(repositoryKey)) {
    RepositoryModel model = loadRepositoryModel(repositoryName);
    ...
}

// cached model
RepositoryModel model = repositoryListCache.get(repositoryKey);
@gitblit

gitblit May 19, 2014

Owner

We have to be careful when manipulating repository look-ups. The cache lookups should be case-insensitive - but the filesystem lookups are case-sensitive on case-sensitive filesystems.

I think the better fix is to ensure that cache lookups use the proper key, but leave the file system loading as-is. Try the following and let me know if that yields the same time-saving result.

String repositoryKey = repositoryName.toLowerCase();
if (!repositoryListCache.containsKey(repositoryKey)) {
    RepositoryModel model = loadRepositoryModel(repositoryName);
    ...
}

// cached model
RepositoryModel model = repositoryListCache.get(repositoryKey);
@gitblit

This comment has been minimized.

Show comment
Hide comment
@gitblit

gitblit May 21, 2014

Owner

@culmat Have you tried my counter proposal?

Owner

gitblit commented May 21, 2014

@culmat Have you tried my counter proposal?

@culmat

This comment has been minimized.

Show comment
Hide comment
@culmat

culmat May 21, 2014

Contributor

Hi James,
haven't tried yet, but in my understanding it must be the same. When you Alt+Shift+I inline in Eclipse it should yield the exact same code?

Contributor

culmat commented May 21, 2014

Hi James,
haven't tried yet, but in my understanding it must be the same. When you Alt+Shift+I inline in Eclipse it should yield the exact same code?

@gitblit

This comment has been minimized.

Show comment
Hide comment
@gitblit

gitblit May 22, 2014

Owner

I pushed my proposed fix.

Owner

gitblit commented May 22, 2014

I pushed my proposed fix.

@gitblit gitblit closed this May 22, 2014

@culmat culmat deleted the culmat:patch-1 branch Sep 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment