当前位置: 首页 > 知识库问答 >
问题:

使用Spring Data Redis访问Redis连接池

陈欣荣
2023-03-14

我想监控并定期记录有关Redis连接池使用情况的信息。

我通过spring-data-redis RedisTemboard对象使用Redis。

有办法进入游泳池吗?

共有1个答案

吴鸿彩
2023-03-14

我能够使用反射API访问内部池。

  private GenericObjectPool<Jedis> jedisPool() {
    try {
      Field pool = JedisConnectionFactory.class.getDeclaredField("pool");
      pool.setAccessible(true);
      Pool<Jedis> jedisPool = (Pool<Jedis>) pool.get(jedisConnectionFactory());
      Field internalPool = Pool.class.getDeclaredField("internalPool");
      internalPool.setAccessible(true);
      return (GenericObjectPool<Jedis>) internalPool.get(jedisPool);
    } catch (NoSuchFieldException | IllegalAccessException e) {
      e.printStackTrace();
    }
  }
 类似资料:
  • 我在本地配置了redis sentinel,在两个不同的端口10001和10002上运行。我有相同的sentinel身份验证设置。 Redis哨兵配置 使用的JAR版本 Spring-data-redis:2.0.10。发布 莴苣(io.莴苣.莴苣芯):5.0.5.RELEASE 在尝试连接到redisSentinelConfiguration时,我一直收到NOAUTH身份验证请求错误 使用Spr

  • 问题内容: 我是Redis的新手…我最近刚拿起Redisent来在PHP中使用Redis …并且我玩得很开心!但是,我注册了Redis服务,并一直在努力使用该服务… URI字符串如下: redis:// [用户名]:[pass] @ [服务器] .redistogo.com:[端口] / Redisent客户端只需输入主机名和端口…并且我没有地方输入用户名/密码…:-/我也一直在摆弄fsockop

  • 我使用spring boot data redis连接到redis群集,使用版本2.1.3,配置如下: 但是,在操作过程中,始终会收到警告异常消息,如下所示: 这似乎是莴苣的问题,如何映射远程主机

  • 主要内容:Redis 连接,1.Auth 命令,2.Echo 命令,3.Ping 命令,4.Quit 命令,5.Select 命令Redis 连接 Redis 连接命令主要是用于连接 redis 服务。 1.Auth 命令 Redis Auth 命令用于检测给定的密码和配置文件中的密码是否相符。 密码匹配时返回 OK ,否则返回一个错误。 2.Echo 命令 Redis Echo 命令用于打印给定的字符串。 3.Ping 命令 Redis Ping 命令使用客户端向 Redis 服务器发送一个

  • 简而言之,我可以运行Elasticsearch吗 我正在Docker(mac)上运行Elasticsearch 6.2.2。使用命令。。 我可以访问Elasticsearch(POST 然而,当从访问docker Elasticsearch实例的不同docker映像运行Dropwizard应用程序时,我使用相同的主机和端口(localhost 9200)拒绝了连接。 当直接从IDE运行Dropwi

  • 我正试图用JedisSentinelPool连接到redis sentinel 这给了我以下错误: 原因:redis.clients.jedis.exceptions.jedisconnectionexception:所有哨兵都关闭了,无法确定mymaster在哪里master正在运行... 但是,我能看到我的哨兵在跑。因此,参考这篇文章:https://github.com/luin/iored