Skip to content

Remove superfluous try catch blocks from Lettuce*Commands [DATAREDIS-1224] #1797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Sep 30, 2020 · 0 comments
Assignees
Labels
type: task A general task

Comments

@spring-projects-issues
Copy link

Christoph Strobl opened DATAREDIS-1224 and commented

The LettuceCommands have repetitive code fragments within try - catch blocks for differentiating between transaction, pipeline and normal command execution.
This can be simplified by using a RedisFuture

return connection.invoke(connection.getAsyncConnection().geodist(key, member1, member2, geoUnit), distanceConverter);

// ...

<S, T> T invoke(RedisFuture<S> future, Converter<S, T> converter) {
	if (isPipelined()) {
		pipeline(newLettuceResult(future, converter));
		return null;
	}
	if (isQueueing()) {
		transaction(newLettuceResult(future, converter));
		return null;
	}
	return NullableResult.of((S) await(future)).convert(converter).get();
}

No further details from DATAREDIS-1224

@spring-projects-issues spring-projects-issues added the type: task A general task label Dec 30, 2020
@mp911de mp911de assigned mp911de and unassigned christophstrobl Jan 19, 2021
mp911de pushed a commit that referenced this issue Jan 21, 2021
mp911de added a commit that referenced this issue Jan 21, 2021
We now use LettuceInvoker to call Lettuce API methods for synchronous, pipelining, and transactional execution models. LettuceInvoker captures the method invocation as functional utility and allows conversion of results:

Long result = invoker.just(RedisGeoAsyncCommands::geoadd, key, point.getX(), point.getY(), member);

List<byte[]> result = invoker.fromMany(RedisGeoAsyncCommands::geohash, key, members)
 				.toList(it -> it.getValueOrElse(null));

Closes #1797
mp911de added a commit that referenced this issue Jan 21, 2021
Use lambdas where possible. Deprecate unused methods. Favor LettuceInvoker conversion methods over List to List/List to Set converters.

See #1797
christophstrobl added a commit that referenced this issue Jan 26, 2021
christophstrobl pushed a commit that referenced this issue Jan 26, 2021
Use lambdas where possible. Deprecate unused methods. Favor LettuceInvoker conversion methods over List to List/List to Set converters.

See #1797
Original Pull Request #1948
@christophstrobl christophstrobl added this to the 2.5 M3 (2021.0.0) milestone Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants