Created
September 30, 2019 16:05
-
-
Save kijanowski/8a00a2f927601c08361c5d396fa30bcb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Bean | |
| @Scope(value = WebApplicationContext.SCOPE_APPLICATION, proxyMode = ScopedProxyMode.TARGET_CLASS) | |
| @Profile("global") | |
| public DataLoaderRegistry globalDataLoaderRegistry( | |
| @Value("${cache.maxCacheSize}") long maxCacheSize, | |
| @Value("${cache.expiryInSeconds}") long expiryInSeconds | |
| ) { | |
| DataLoaderRegistry dataLoaderRegistry = new DataLoaderRegistry(); | |
| CacheMap customCache = new CustomGuavaBasedCache(maxCacheSize, expiryInSeconds); | |
| DataLoaderOptions options = DataLoaderOptions.newOptions().setCacheMap(customCache); | |
| DataLoader<String, CountryTO> countryLoader = DataLoader.newDataLoader(graphQLDataFetchers.countryBatchLoader(), options); | |
| dataLoaderRegistry.register("countries", countryLoader); | |
| return dataLoaderRegistry; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment