Skip to content
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

Add support for configuring the Redis database using spring.data.redis.url #43810

Closed
Demonese opened this issue Jan 14, 2025 · 3 comments
Closed
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@Demonese
Copy link

Demonese commented Jan 14, 2025

Both Jedis and Lettese clients support specifying a database in the URL

Unfortunately, spring-boot-autoconfigure ignore them

	@Override
	public Standalone getStandalone() {
		if (this.properties.getUrl() != null) {
			ConnectionInfo connectionInfo = connectionInfo(this.properties.getUrl());
			return Standalone.of(connectionInfo.getUri().getHost(), connectionInfo.getUri().getPort(),
					this.properties.getDatabase());
		}
		return Standalone.of(this.properties.getHost(), this.properties.getPort(), this.properties.getDatabase());
	}

This causes the following URL actually connect to database 0

spring:
  data:
    redis:
      url: redis://127.0.0.1:6379/8

The current workaround in my project is

spring:
  data:
    redis:
      url: redis://127.0.0.1:6379/8
      database: 8

: (

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 14, 2025
@snicoll
Copy link
Member

snicoll commented Jan 14, 2025

@Demonese this is working as advertized. The documentation of the spring.data.redis.url property you used states:

Connection URL. Overrides host, port, username, and password. Example: redis:// user:password@example. com:6379

@mp911de do you think adding support for the database there would be useful?

@snicoll snicoll added the status: waiting-for-internal-feedback An issue that needs input from a member or another Spring Team label Jan 14, 2025
@mp911de
Copy link
Member

mp911de commented Jan 14, 2025

It would be. When a URL is provided, arguments provided through the URL should take precedence over other properties.

quaff added a commit to quaff/spring-boot that referenced this issue Jan 14, 2025
Fix spring-projectsGH-43810

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
quaff added a commit to quaff/spring-boot that referenced this issue Jan 14, 2025
Fix spring-projectsGH-43810

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
@wilkinsona wilkinsona changed the title Spring Data Redis: spring-boot-autoconfigure ignore the database part in the Redis connection URL Add support for configuring the database using spring.data.redis.url Jan 14, 2025
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged status: waiting-for-internal-feedback An issue that needs input from a member or another Spring Team labels Jan 14, 2025
@wilkinsona wilkinsona added this to the 3.x milestone Jan 14, 2025
@wilkinsona wilkinsona changed the title Add support for configuring the database using spring.data.redis.url Add support for configuring the Redis database using spring.data.redis.url Jan 15, 2025
@wilkinsona
Copy link
Member

Closing in favour of #43813.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2025
@wilkinsona wilkinsona added the status: superseded An issue that has been superseded by another label Jan 15, 2025
@wilkinsona wilkinsona removed this from the 3.x milestone Jan 15, 2025
quaff added a commit to quaff/spring-boot that referenced this issue Jan 16, 2025
Fix spring-projectsGH-43810

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
quaff added a commit to quaff/spring-boot that referenced this issue Jan 23, 2025
Fix spring-projectsGH-43810

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants