@Test
public void testCachingPerDbPerResolver() {

    KeySpace keySpace = new KeySpace(
            new KeySpaceDirectory("resolver1", KeyType.STRING, "resolver1"),
            new KeySpaceDirectory("resolver2", KeyType.STRING, "resolver2"));
    LocatableResolver resolver1;
    LocatableResolver resolver2;
    FDBStoreTimer timer = new FDBStoreTimer();
    try (FDBRecordContext context = database.openContext()) {
        resolver1 = scopedDirectoryGenerator.apply(database, keySpace.path("resolver1").toResolvedPath(context));
        resolver2 = scopedDirectoryGenerator.apply(database, keySpace.path("resolver2").toResolvedPath(context));
        context.setTimer(timer);
        for (int i = 0; i < 10; i++) {
            resolver1.getVersion(context.getTimer()).join();
        }
        assertThat("We only read the value once", timer.getCount(FDBStoreTimer.DetailEvents.RESOLVER_STATE_READ), is(1));
        timer = new FDBStoreTimer();
        assertThat("count is reset", timer.getCount(FDBStoreTimer.DetailEvents.RESOLVER_STATE_READ), is(0));
        context.setTimer(timer);
        resolver2.getVersion(context.getTimer()).join();
        assertThat("We have to read the value for the new resolver", timer.getCount(FDBStoreTimer.DetailEvents.RESOLVER_STATE_READ), is(1));
        LocatableResolver newResolver1 = scopedDirectoryGenerator.apply(database, keySpace.path("resolver1").toResolvedPath(context));
        timer = new FDBStoreTimer();
        assertThat("count is reset", timer.getCount(FDBStoreTimer.DetailEvents.RESOLVER_STATE_READ), is(0));
        context.setTimer(timer);
        for (int i = 0; i < 10; i++) {
            newResolver1.getVersion(context.getTimer()).join();
        }
        assertThat("we still hit the cache", timer.getCount(FDBStoreTimer.DetailEvents.RESOLVER_STATE_READ), is(0));
    }
}