@Override
    public Name getLocation(final Path file) throws BackgroundException {
        final Path container = containerService.getContainer(file);
        if(container.isRoot()) {
            return unknown;
        }
        if(cache.containsKey(container)) {
            return cache.get(container);
        }
        if(Location.unknown.equals(new SwiftRegion(container.attributes().getRegion()))) {
            final SwiftRegion region = new SwiftRegion(session.getHost().getRegion());
            if(Location.unknown.equals(region)) {
                final Client client = session.getClient();
                for(Region r : client.getRegions()) {
                    try {
                        cache.put(container, new SwiftRegion(client.getContainerInfo(r, container.getName()).getRegion().getRegionId()));
                    }
                    catch(ContainerNotFoundException | AuthorizationException e) {
                        log.warn(String.format("Failure finding container %s in region %s", container, r.getRegionId()));
                    }
                    catch(GenericException e) {
                        if(e.getHttpStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE) {
                            log.warn(String.format("Ignore failure %s for region %s", e, region));
                            continue;
                        }
                        throw new SwiftExceptionMappingService().map(e);
                    }
                    catch(IOException e) {
                        throw new DefaultIOExceptionMappingService().map(e);
                    }
                }
                if(!cache.containsKey(container)) {
                    throw new NotfoundException(container.getAbsolute());
                }
            }
            else {
                cache.put(container, region);
            }
        }
        else {
            final SwiftRegion r = new SwiftRegion(container.attributes().getRegion());
            cache.put(container, r);
        }
        return cache.get(container);
    }
@Test
    public void testCache() throws Exception {
        final SwiftLocationFeature feature = new SwiftLocationFeature(session);
        assertEquals(new SwiftLocationFeature.SwiftRegion("IAD"), feature.getLocation(
            new Path("cdn.duck.sh", EnumSet.of(Path.Type.volume, Path.Type.directory))));
// Cache
        assertEquals(new SwiftLocationFeature.SwiftRegion("IAD"), feature.getLocation(
            new Path("cdn.duck.sh", EnumSet.of(Path.Type.volume, Path.Type.directory))));
    }