Redis缓存服务器缓存数据
来源:互联网 发布:windows 输出到文件 编辑:程序博客网 时间:2024/04/29 10:37
- 工具类
public class JedisPoolUtils { private static JedisPool pool = null; static{ //加载配置文件 InputStream in = JedisPoolUtils.class.getClassLoader().getResourceAsStream("redis.properties"); Properties pro = new Properties(); try { pro.load(in); } catch (IOException e) { e.printStackTrace(); } //获得池子对象(redis数据库) JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxIdle(Integer.parseInt(pro.get("redis.maxIdle").toString()));//最大闲置个数 poolConfig.setMinIdle(Integer.parseInt(pro.get("redis.minIdle").toString()));//最小闲置个数 poolConfig.setMaxTotal(Integer.parseInt(pro.get("redis.maxTotal").toString()));//最大连接数 pool = new JedisPool(poolConfig,pro.getProperty("redis.url") , Integer.parseInt(pro.get("redis.port").toString())); } //获得jedis资源的方法 public static Jedis getJedis(){ return pool.getResource(); } public static void main(String[] args) { Jedis jedis = getJedis(); System.out.println(jedis.get("xxx")); }}
- redis.properties配置文件
redis.maxIdle=30redis.minIdle=10redis.maxTotal=100redis.url=localhostredis.port=6379
- 调用到redis缓存的方法
public void findAllCategory(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 获取redis连接 Jedis jedis = JedisPoolUtils.getJedis(); // 获取json_list String json_list = jedis.get("json_list"); System.out.println(json_list); if (json_list == null) { List<Category> list = cs.findAllCategories(); json_list = JSONArray.fromObject(list).toString(); // 缓存json_list jedis.set("json_list", json_list); } response.getWriter().println(json_list); }
阅读全文
0 0
- Redis缓存服务器缓存数据
- spring+redis缓存服务器读取不到数据
- redis作为缓存服务器
- Redis缓存php数据
- redis缓存 脏数据
- 采用redis缓存数据
- 使用redis缓存数据
- REDIS实现数据缓存
- redis缓存分页数据
- springboot redis 数据缓存
- 数据缓存---Spring Redis Cache 缓存
- Redis缓存服务器的配置
- Redis缓存服务器安装部署
- spring+redis做数据缓存
- 用redis缓存mongodb数据
- thinkphp5 配置redis数据缓存
- Spring Boot Redis 数据缓存
- 缓存数据redis的配置-
- 大统一!微软谷歌 W3C 把 Web 文档迁移至 MDN
- 浏览器的渲染:过程与原理
- 学习心得
- 04-树6 Complete Binary Search Tree(30 分)
- [贪心] 51Nod1380 夹克老爷的逢三抽一
- Redis缓存服务器缓存数据
- Go 多值函数和string练手
- line-height属性技巧
- 获取网络数据工具类
- all:用途
- 详解 Tomcat 配置文件 server.xml
- count(列名)与count(*)说明
- webview 的网页显示
- DHT应用于区块链概要