• Bug
  • Status: Closed
  • Resolution: Fixed
  • drb
  • Reporter: sourceforgetracker
  • September 21, 2009
  • 0
  • Watchers: 0
  • September 22, 2009
  • September 22, 2009

Description

Hi,

The construction of a Cache instance has a bottleneck in the code: InetAddress.getLocalHost()

For most uses of EHCache, this will not be an issue.
It is only when caches are created, used and discarded rapidly that the issue arises.

It would be appropriate to add the following:

private static final InetAddress LOCALHOST = InetAddress.getLocalHost();

This could be reused:

private String guid;

{
    try {
        guid = new StringBuffer()
                .append(LOCALHOST)
                .append("-")
                .append(new UID())
                .toString();
    } catch (UnknownHostException e) {
        LOG.error("Could not create GUID: " +  e.getMessage());
    }
}

Sourceforge Ticket ID: 1488853 - Opened By: dhulley - 15 May 2006 13:24 UTC

Comments

Sourceforge Tracker 2009-09-21

Logged In: YES user_id=693320

Derek

I made the change. I altered your LOCALHOST initializer a little as follows:

private static InetAddress LOCALHOST; 

static {
    try {
        LOCALHOST = InetAddress.getLocalHost();
    } catch (UnknownHostException e) {
        LOG.error("Unable to set localhost. This prevents creation of a GUID.  Cause was: " + e.getMessage(), e);
    }
}

This will be in svn trunk shortly and released in ehcache-1.2.1. Comment by: gregluck - 15 May 2006 22:53 UTC

Fiona OShea 2009-09-22

Re-opening so that I can properly close out these issues and have correct Resolution status in Jira