专注JavaWeb开发 首页制式『默认式 OR 时间轴 网站地图|RSS订阅|设为首页|加入收藏
当前位置:首页 >Java >Java工具类 > 正文

Redis URI and connection details

作者: 紫寒1120 发布时间: 2019-05-07 浏览次数:

Connections to a Redis Standalone, Sentinel, or Cluster require a specification of the connection details. The unified form is RedisURI. You can provide the database, password and timeouts within the RedisURI. You have following possibilities to create a RedisURI:

  1. Use an URI:

    RedisURI.create("redis://localhost/");
  2. Use the Builder

    RedisURI.Builder.redis("localhost", 6379).auth("password").database(1).build();
  3. Set directly the values in RedisURI

    new RedisURI("localhost", 6379, 60, TimeUnit.SECONDS);

URI syntax

Redis Standalone

redis :// [: password@] host [: port] [/ database][? [timeout=timeout[d|h|m|s|ms|us|ns]] [&_database=database_]]

Redis Standalone (SSL)

rediss :// [: password@] host [: port] [/ database][? [timeout=timeout[d|h|m|s|ms|us|ns]] [&_database=database_]]

Redis Standalone (Unix Domain Sockets)

redis-socket :// path [?[timeout=timeout[d|h|m|s|ms|us|ns]][&_database=database_]]

Redis Sentinel

redis-sentinel :// [: password@] host1[: port1] [, host2[: port2]] [, hostN[: portN]] [/ database][?[timeout=timeout[d|h|m|s|ms|us|ns]] [&_sentinelMasterId=sentinelMasterId_] [&_database=database_]]

Schemes

  • redis Redis Standalone

  • rediss Redis Standalone SSL

  • redis-socket Redis Standalone Unix Domain Socket

  • redis-sentinel Redis Sentinel

Timeout units

  • d Days

  • h Hours

  • m Minutes

  • s Seconds

  • ms Milliseconds

  • us Microseconds

  • ns Nanoseconds

Hint: The database parameter within the query part has higher precedence than the database in the path.

RedisURI supports Redis Standalone, Redis Sentinel and Redis Cluster with plain, SSL, TLS and unix domain socket connections.


QQ群: 武汉地区(142173356)验证消息JavaWeb1024

网友共有【】评论,点击查看


相关新闻:


x 微信关注我们 随时获取最新网站资讯