/** * Loads the values via a stored key file into the supplied {@link DataStructureAdapter}. * * @param adapter the {@link DataStructureAdapter} to load the values from */ public void loadKeys(DataStructureAdapter<Object, ?> adapter) { if (!storeFile.exists()) { logger.info(format("Skipped loading keys of Near Cache %s since storage file doesn't exist (%s)", nearCacheName, storeFile.getAbsolutePath())); return; } long startedNanos = System.nanoTime(); BufferingInputStream bis = null; try { bis = new BufferingInputStream(new FileInputStream(storeFile), BUFFER_SIZE); if (!checkHeader(bis)) { return; } int loadedKeys = loadKeySet(bis, adapter); long elapsedMillis = getElapsedMillis(startedNanos); logger.info(format("Loaded %d keys of Near Cache %s in %d ms", loadedKeys, nearCacheName, elapsedMillis)); } catch (Exception e) { logger.warning(format("Could not pre-load Near Cache %s (%s)", nearCacheName, storeFile.getAbsolutePath()), e); } finally { closeResource(bis); } }
/** * Loads the values via a stored key file into the supplied {@link DataStructureAdapter}. * * @param adapter the {@link DataStructureAdapter} to load the values from */ public void loadKeys(DataStructureAdapter<Object, ?> adapter) { if (!storeFile.exists()) { logger.info(format("Skipped loading keys of Near Cache %s since storage file doesn't exist (%s)", nearCacheName, storeFile.getAbsolutePath())); return; } long startedNanos = System.nanoTime(); BufferingInputStream bis = null; try { bis = new BufferingInputStream(new FileInputStream(storeFile), BUFFER_SIZE); if (!checkHeader(bis)) { return; } int loadedKeys = loadKeySet(bis, adapter); long elapsedMillis = getElapsedMillis(startedNanos); logger.info(format("Loaded %d keys of Near Cache %s in %d ms", loadedKeys, nearCacheName, elapsedMillis)); } catch (Exception e) { logger.warning(format("Could not pre-load Near Cache %s (%s)", nearCacheName, storeFile.getAbsolutePath()), e); } finally { closeResource(bis); } }