class SlotMapper {

    public String map(long time, String service)
    {
        // I am going out on a limb here assuming that if we come across
        // log messages that come from before 1970 you won't be too upset
        // about me blatantly assuming they may be a bit fishy.
        if (time < 0) {
            throw new IllegalArgumentException("Timestamp was less than zero");
        }

        long slotnum = time / SLOT_LENGTH;
        String slot = slotCache.get(slotnum);

        // If a slot was not found we calculate the path for that slot
        // and add it to the cache
        if (null == slot) {
            // Take this opportunity to possibly nuke the entire cache
            // if it has grown beyond LARGE_CACHE number of entries.
            // For all but the most degenerate use-cases this should not
            // affect performance noticably
            if (slotCache.size() > LARGE_CACHE) {
                slotCache.clear();
            }

            slot = mapToPath(time, service);
            slotCache.put(slotnum, slot);
        }

        return slot;
    }

}