当前位置: 首页 > news >正文

RedisTemplate 怎么获取到链接信息?怎么获取到所有key?怎么获取指定key?

获取Redis的链接信息:

(RedisTemplate<String, ?> redisTemplate) {RedisConnectionFactory connectionFactory = redisTemplate.getConnectionFactory();(!(connectionFactory LettuceConnectionFactory)) {System..println();;}LettuceConnectionFactory lettuceConnectionFactory = (LettuceConnectionFactory) connectionFactory;RedisConnection connection = connectionFactory.getConnection();(connection == || connection.isClosed()) {System..println();} {System..println();String host = lettuceConnectionFactory.getHostName();port = lettuceConnectionFactory.getPort();System..println(+ host);System..println(+ port);System..println(+ connection.info());}
}

获取指定的key:

Set<String> (RedisTemplate<String, ?> redisTemplate) {ScanOptions scanOptions = ScanOptions.().match().count().build();Set<String> keys = redisTemplate.execute(connection -> {Set<[]> keysBytes = connection.keys(.getBytes());keysBytes.stream().map(String::).collect(Collectors.());}, );keys;
}

获取所有key:

Set<String> (RedisTemplate<String, ?> redisTemplate,String hashKey) {HashOperations<String, String, Object> hashOperations = redisTemplate.opsForHash();hashOperations.keys(hashKey);
}

http://www.lryc.cn/news/275788.html

相关文章:

  • 【Unity】动态申请权限
  • tp8/6 插件PhpOffice\PhpSpreadsheet导入表格
  • Android studio VideoView 应用设计
  • Python基础(十八、文件操作读取)
  • Mac 16g约等于Windows多少g?
  • 快麦ERP退货借助APPlink快速同步CRM
  • springMVC获取请求参数的方式
  • android常用方法
  • Linux内核--网络协议栈(一)Socket通信原理和实例讲解
  • Spring事务(2):声明式事务管理案例-转账(xml、注解)
  • NACHI机器人模拟示教器如何切换中文
  • 用通俗易懂的方式讲解:使用 Mistral-7B 和 Langchain 搭建基于PDF文件的聊天机器人
  • 综合智慧能源监测管理平台,实现能源管理“透明”化
  • 【大数据进阶第三阶段之Datax学习笔记】使用阿里云开源离线同步工具DataX 实现数据同步
  • kotlin chunked 和 windowed
  • C语言光速入门笔记
  • Flutter+Go_Router+Fluent_Ui仿阿里网盘桌面软件开发跨平台实战-买就送仿小米app开发
  • 内联函数的作用
  • Simpy简介:python仿真模拟库-02/5
  • Kafka高级应用:如何配置处理MQ百万级消息队列?
  • LIN总线学习笔记(1)-总线传输规范
  • Qt界面篇:Qt停靠控件QDockWidget、树控件QTreeWidget及属性控件QtTreePropertyBrowser的使用
  • H266/VVC网络适配层概述
  • new FormData 同时发送表单 json 以及文件二进制流
  • 计算机环境安全
  • Activiti7工作流引擎:多租户
  • Postman实现压力测试
  • 爬虫工具(tkinter+scrapy+pyinstaller)
  • MySQL常用sql语句记录
  • 2024.1.4力扣每日一题——被列覆盖的最多行数