Skip to content

Instantly share code, notes, and snippets.

@yangl
Last active September 15, 2021 12:09
Show Gist options
  • Save yangl/7038eb963c052640aa0c470173f6697e to your computer and use it in GitHub Desktop.
Save yangl/7038eb963c052640aa0c470173f6697e to your computer and use it in GitHub Desktop.
解决Lettuce在多分片时线程数过多问题,需单独配置ioThreadPoolSize&computationThreadPoolSize然后共享eventExecutorGroup,非-Dio.netty.eventLoopThreads=… https://lettuce.io/
ClientResources.builder().ioThreadPoolSize(…).computationThreadPoolSize(…).eventExecutorGroup(...).build()
EventExecutorGroup eventExecutorGroup = DefaultEventLoopGroupProvider.createEventLoopGroup(DefaultEventExecutorGroup.class,
computationThreadPoolSize, threadFactoryProvider);
/**
* Create a new client that connects to the supplied uri with shared {@link ClientResources}.You need to shut down the
* {@link ClientResources} upon shutting down your application. You can connect to different Redis servers but you must
* supply a {@link RedisURI} on connecting.
*
* @param clientResources the client resources, must not be {@code null}.
* @param uri the Redis URI, must not be {@code null}.
* @return a new instance of {@link RedisClient}.
*/
public static RedisClient create(ClientResources clientResources, String uri) {
assertNotNull(clientResources);
LettuceAssert.notEmpty(uri, "URI must not be empty");
return create(clientResources, RedisURI.create(uri));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment