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

网站建设柒金手指下拉二一公司网站设计规范

网站建设柒金手指下拉二一,公司网站设计规范,做网站的技术员,wordpress js代码插件Redis 批量操作 如果频繁地使用Redis#xff0c;比如在 for循环中调用 redis#xff0c;有时可能会报错#xff1a; Could not get a resource from the pool。 这是因为 Redis的连接数是有限的#xff0c;打开了Redis的连接#xff0c;用完记得要关闭#xff0c;如果连…Redis 批量操作 如果频繁地使用Redis比如在 for循环中调用 redis有时可能会报错 Could not get a resource from the pool。 这是因为 Redis的连接数是有限的打开了Redis的连接用完记得要关闭如果连接数不够了就会报错。 Redis 批量操作可以使用 RedisTemplate 的 execute()方法。 RedisTemplate 源码 org.springframework.data.redis.core.RedisOperations org.springframework.data.redis.core.RedisTemplate RedisTemplate 的 execute()方法 org.springframework.data.redis.core.RedisTemplate#execute(org.springframework.data.redis.core.SessionCallback) execute() 方法可以在一次连接中进行多个命令操作。执行完会自动关闭连接。 /*** Executes a Redis session. Allows multiple operations to be executed in the same session enabling transactional* capabilities through {link #multi()} and {link #watch(Collection)} operations.** param T return type* param session session callback. Must not be {literal null}.* return result object returned by the action or ttnull/tt*/Overridepublic T T execute(SessionCallbackT session) {Assert.isTrue(initialized, template not initialized; call afterPropertiesSet() before using it);Assert.notNull(session, Callback object must not be null);RedisConnectionFactory factory getRequiredConnectionFactory();// 打开连接RedisConnectionUtils.bindConnection(factory, enableTransactionSupport);try {return session.execute(this);} finally {//执行完会自动关闭连接RedisConnectionUtils.unbindConnection(factory);}}execute()的SessionCallback参数和RedisCallback参数 SessionCallback 比 RedisCallck 更好些优先使用 SessionCallback 。 使用SessionCallback , 还可以配合multi() 和 watch() 进行事务操作。 /*** Executes the given action within a Redis connection. Application exceptions thrown by the action object get* propagated to the caller (can only be unchecked) whenever possible. Redis exceptions are transformed into* appropriate DAO ones. Allows for returning a result object, that is a domain object or a collection of domain* objects. Performs automatic serialization/deserialization for the given objects to and from binary data suitable* for the Redis storage. Note: Callback code is not supposed to handle transactions itself! Use an appropriate* transaction manager. Generally, callback code must not touch any Connection lifecycle methods, like close, to let* the template do its work.** param T return type* param action callback object that specifies the Redis action. Must not be {literal null}.* return a result object returned by the action or ttnull/tt*/ Nullable T T execute(RedisCallbackT action);/*** Executes a Redis session. Allows multiple operations to be executed in the same session enabling transactional* capabilities through {link #multi()} and {link #watch(Collection)} operations.** param T return type* param session session callback. Must not be {literal null}.* return result object returned by the action or ttnull/tt*/ Nullable T T execute(SessionCallbackT session);execute() 使用示例 Autowiredprivate StringRedisTemplate stringRedisTemplate;public void testExecute() {String userId userId;stringRedisTemplate.opsForValue().set(userId123, lin);stringRedisTemplate.opsForValue().set(userId456, wu);stringRedisTemplate.opsForValue().set(userId789, chen);MapString, String map new HashMap();stringRedisTemplate.execute(new SessionCallbackString() {Overridepublic K, V String execute(NonNull RedisOperationsK, V redisOperations) throws DataAccessException {ListString list Arrays.asList(123, 456, 789);for (String id : list) {String key userId id;String value (String) redisOperations.opsForValue().get(key);map.put(key, value);}return null;}});map.forEach((k, v) - System.out.println(k ,val: v));}
http://www.zqtcl.cn/news/14116/

相关文章:

  • 物流网站建设目标公司的网站如何建设方案
  • 用html制作个人网站湘潭找工作网站
  • 网站推广有什么方法有哪些宜昌市住房城乡建设网站
  • 旅游网站建设服务网站地图的使用
  • diy网站新能源电动汽车
  • 网站建设锚点链接psd做成网站
  • asp网站用什么数据库制作单页网站
  • 婚恋网站制作要多少钱网站开发合同审核要点
  • 送给做网站的锦旗语提高审美的网站推荐
  • 什么网站可以找到做餐饮的会计wordpress论坛查看用户密码
  • 中国室内设计网站官网四平网站建设
  • 福田网站网页设计手机网站可以直接做百度推广不
  • 个人站长做导航网站怎么创建
  • 微信网页制作网站建设东莞建设银行各网点营业时间查询
  • 怎么做网站seo优化wordpress升级后出错
  • 手机网站与app的区别如何再工商局网站做设备抵押
  • 电子商务网站架构软件开发系统设计
  • php能做手机网站吗网站建设论文ppt
  • 有没有可以做翻译的网站吗微信公众号如何开通
  • 大丰网站制作北京建网站实力公司
  • 建设工程 质量 协会网站中山网站搜索引擎优化
  • 郴州公司做网站thinkphp网站开发技术
  • 网站模板源码下载网网站的栏目关键词
  • 河北企业建网站广州中小企业seo推广运营
  • 郑州建设网站费用wordpress简单用户中心
  • 网站规划方案模板站长工具seo综合查询论坛
  • 句容市建设局网站廊坊市网站
  • 公司建网站多少钱一个深圳网站制作公司售后
  • 网站后台默认用户名昆山网站开发的公司
  • 厦门做网站xm37芜湖网站建设推广公司