首页 文章 精选 留言 我的

精选列表

搜索[AI功能],共10000篇文章
优秀的个人博客,低调大师

额外功能

10.1. 对Redis节点的操作 Redisson的NodesGroup对象提供了许些对Redis节点的操作。 NodesGroup nodesGroup = redisson.getNodesGroup(); nodesGroup.addConnectionListener(new ConnectionListener() { public void onConnect(InetSocketAddress addr) { // Redis节点连接成功 } public void onDisconnect(InetSocketAddress addr) { // Redis节点连接断开 } }); 也可以用来PING单个Redis节点或全部节点。 NodesGroup nodesGroup = redisson.getNodesGroup(); Collection<Node> allNodes = nodesGroup.getNodes(); for (Node n : allNodes) { n.ping(); } // 或者 nodesGroup.pingAll(); 10.2. 复杂多维对象结构和对象引用的支持 Redisson突破了Redis数据结构维度的限制,通过一个特殊引用对象的帮助,Redisson允许以任意的组合方式构建多维度的复杂对象结构,实现了对象之间的类似传统数据库里的关联关系。使用范例如下: RMap<RSet<RList>, RList<RMap>> map = redisson.getMap("myMap"); RSet<RList> set = redisson.getSet("mySet"); RList<RMap> list = redisson.getList("myList"); map.put(set, list); // 在特殊引用对象的帮助下,我们甚至可以构建一个循环引用,这是通过普通序列化方式实现不了的。 set.add(list); list.add(map); 可能您已经注意到了,在map包含的元素发生改变以后,我们无需再次“保存/持久”这些对象。因为map对象所记录的并不是序列化以后的值,而是元素对象的引用。这让Redisson提供的对象在使用方法上,与普通Java对象的使用方法一致。从而让Redis成为内存的一部分,而不仅仅是一个储存空间。 以上范例中,一共创建了三个Redis数据结构:一个Redis HASH,一个Redis SET和一个Redis LIST。 10.3. 命令的批量执行 多个连续命令可以通过RBatch对象在一次网络会话请求里合并发送,这样省去了产生多个请求消耗的时间和资源。这在Redis中叫做管道。 RBatch batch = redisson.createBatch(); batch.getMap("test").fastPutAsync("1", "2"); batch.getMap("test").fastPutAsync("2", "3"); batch.getMap("test").putAsync("2", "5"); batch.getAtomicLongAsync("counter").incrementAndGetAsync(); batch.getAtomicLongAsync("counter").incrementAndGetAsync(); // 原子化(事务)批量执行所有的命令 batch.atomic(); // 告知Redis不用返回结果(可以减少网络用量) batch.skipResult(); // 将写入操作同步到从节点 // 同步到2个从节点,等待时间为1秒钟 batch.syncSlaves(2, 1, TimeUnit.SECONDS) // 处理结果超时为2秒钟 batch.timeout(2, TimeUnit.SECONDS); // 命令重试等待间隔时间为2秒钟 batch.retryInterval(2, TimeUnit.SECONDS); // 命令重试次数,仅适用于未发送成功的命令 batch.retryAttempts(4); BatchResult res = batch.execute(); // 或者 Future<BatchResult> asyncRes = batch.executeAsync(); 在集群模式下,所有的命令会按各个槽所在的节点,筛选分配到各个节点并同时发送。每个节点返回的结果将会汇总到最终的结果列表里。 10.4. 脚本执行 redisson.getBucket("foo").set("bar"); String r = redisson.getScript().eval(Mode.READ_ONLY, "return redis.call('get', 'foo')", RScript.ReturnType.VALUE); // 通过预存的脚本进行同样的操作 RScript s = redisson.getScript(); // 首先将脚本保存到所有的Redis主节点 String res = s.scriptLoad("return redis.call('get', 'foo')"); // 返回值 res == 282297a0228f48cd3fc6a55de6316f31422f5d17 // 再通过SHA值调用脚本 Future<Object> r1 = redisson.getScript().evalShaAsync(Mode.READ_ONLY, "282297a0228f48cd3fc6a55de6316f31422f5d17", RScript.ReturnType.VALUE, Collections.emptyList()); 10.5. 底层Redis客户端 Redisson在底层采用了高性能异步非阻塞式Java客户端,它同时支持异步和同步两种通信模式。如果有哪些命令Redisson还没提供支持,也可以直接通过调用底层Redis客户端来实现。Redisson支持的命令在Redis命令和Redisson对象匹配列表里做了详细对比参照。 // 在使用多个客户端的情况下可以共享同一个EventLoopGroup EventLoopGroup group = new NioEventLoopGroup(); RedisClientConfig config = new RedisClientConfig(); config.setAddress("redis://localhost:6379") // 或者用rediss://使用加密连接 .setPassword("myPassword") .setDatabase(0) .setClientName("myClient") .setGroup(group); RedisClient client = RedisClient.create(config); RedisConnection conn = client.connect(); // 或 RFuture<RedisConnection> connFuture = client.connectAsync(); conn.sync(StringCodec.INSTANCE, RedisCommands.SET, "test", 0); // 或 conn.async(StringCodec.INSTANCE, RedisCommands.GET, "test"); conn.close() // 或 conn.closeAsync() client.shutdown(); // 或 client.shutdownAsync();

优秀的个人博客,低调大师

智能农业物联网系统功能分析

随着农业物联网技术广泛应用在农业生产中后,越来越多的人放弃了传统的耕作方式,开始使用农业物联网系统来实现农业的精准管理和轻松化管理。农业物联网系统将彻底转变农业生产者的管理理念,改变过去生产者单纯依靠经验进行农业生产经营的模式。 对于菜农来说,凭经验给作物施肥、浇水、打药,这是很寻常的事情,但当菜农们看到设施农业生产基地中的蔬菜不需要人工去浇水,也可以得到适量的水分条件时,菜农们终于发现靠感觉施肥、浇水、打药并不是管理农田的唯一方法。物联网技术在农业中的应用,既能改变粗放的农业经营管理方式,也能提高动植物疫情疫病防控能力,确保农产品质量安全,引领现代农业发展。 农业物联网系统组成:数据采集系统。主要负责温室内部光照、温度、湿度和土壤含水量以及视频等数据的采集和控制。数据传感器的上传采用ZigBee和Rs485两种模式。根据传输方式的不同,温室现场部署分为无线版和有线版两种。无线版采用ZigBee发送模块将传感器的数值传送到zigBee节点上;有线版采用电缆方式将数据传送到Rs485节点上。无线版具有部署灵活,扩展方便等优点;有线版具有高速部署,数据稳定等优点。 视频采集系统。该系统采用高精度网络摄像机,系统的清晰度和稳定性等参数均符合国内相关标准。 控制系统。该系统主要由控制设备和相应的继电器控制电路组成,通过继电器可以自由控制各种农业生产设备,包括:喷淋、滴灌等喷水系统和卷帘、风机等空气调节系统等。 无线传输系统。该系统主要将设备采集到的数据,通过3G网络传送到服务器上,在传输协议上支持IPv4现网协议及下一代互联网IPv6协议。 数据处理系统。该系统负责对采集的数据进行存储和信息处理,为用户提供分析和决策依据,用户可随时随地通过电脑和手机等终端进行查询。 农业物联网系统能够采集农作物生长环境信息,能够有效改善农作物生态环境。基于精准的农作物传感器进行实时监测,利用云计算、数据挖掘等技术进行多层次分析,并将分析指令与各种控制设备进行联动完成农业生产、管理,显著提高农业生产经营效率。 农业物联网系统能够在无人化管理的过程中种好蔬果,解决了农业劳动力日益紧缺的问题。目前农业劳动力不足是农业生产中面临的一个主要问题之一,通过实施农作物物联网系统可以实现一个人管理多个大棚,一个人开展大面积的土壤施肥和灌溉,因此有效解决了农业劳动力日益紧缺的问题,同时也实现了农业生产高度规模化、集约化、工厂化。

优秀的个人博客,低调大师

jquery源码03 (3184 , 3295) support : 功能检测

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script src="jquery-2.0.3.js"></script> <script> $(function(){ for(var attr in $.support){ $('body').append( '<div>'+attr+':'+$.support[attr]+'</div>' ); } /* 根据这些属性,判断浏览器类型 checkOn:true optSelected:true reliableMarginRight:true boxSizingReliable:true pixelPosition:false noCloneChecked:true optDisabled:true radioValue:true checkClone:true focusinBubbles:false clearCloneStyle:true cors:true ajax:true */ var oDiv = document.getElementById('div1'); oDiv.onfocusin = function(){//鼠标移入事件 alert(123); }; var div = document.createElement('div'); div.style.backgroundColor = 'red'; div.cloneNode(true).style.backgroundColor = ''; alert( div.style.backgroundColor ); var div = $('<div>'); div.css('backgroundColor','red'); div.clone().css('backgroundColor',''); alert( div.css('backgroundColor') ); }); </script> </head> <body> <div id="div1"> <input type="text"> </div> </body> </html> //兼容性,support是做兼容性检测,检测完之后实施是通过钩子机制。 jQuery.support = (function( support ) {//右边函数会立即执行 var input = document.createElement("input"), fragment = document.createDocumentFragment(),//文档碎片 div = document.createElement("div"), select = document.createElement("select"), opt = select.appendChild( document.createElement("option") ); // input.type默认是text,基本都有, if ( !input.type ) { return support; } //改成复选框 input.type = "checkbox"; //新版本value的值是'on',老版本value的值是'',所以新本版support.checkOn=true,老版本support.checkOn=false,就可以通过support.checkOn属性值进行浏览器类型判断。 support.checkOn = input.value !== ""; // 狐火chrome下拉子项默认是选中的,ie默认不选中。 support.optSelected = opt.selected; // 定义初始值 support.reliableMarginRight = true; support.boxSizingReliable = true; support.pixelPosition = false; // Make sure checked status is properly cloned // Support: IE9, IE10 //先让input选中,然后克隆,再判断选中状态,火狐chromeIE10以上都是选中的,ie低版本不是选中。 input.checked = true; support.noCloneChecked = input.cloneNode( true ).checked; // Make sure that the options inside disabled selects aren't marked as disabled // (WebKit marks them as disabled) //下拉菜单禁止,子项有没有禁止。 select.disabled = true; support.optDisabled = !opt.disabled; // Check if an input maintains its value after becoming a radio // Support: IE9, IE10 input = document.createElement("input"); input.value = "t"; input.type = "radio"; support.radioValue = input.value === "t"; // #11217 - WebKit loses check when the name is after the checked attribute input.setAttribute( "checked", "t" ); input.setAttribute( "name", "t" ); fragment.appendChild( input ); // Support: Safari 5.1, Android 4.x, Android 2.3 // old WebKit doesn't clone checked state correctly in fragments support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; // Support: Firefox, Chrome, Safari // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) support.focusinBubbles = "onfocusin" in window; //首先定义一个div的背景剪切是内容剪切,然后复制一份设置背景剪切为空,然后看原来div的背景剪切还是不是内容剪切。 div.style.backgroundClip = "content-box"; div.cloneNode( true ).style.backgroundClip = ""; support.clearCloneStyle = div.style.backgroundClip === "content-box"; //下面的需要等dom加载完才能检测 jQuery(function() { var container, marginDiv, // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). // divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box", body = document.getElementsByTagName("body")[ 0 ]; if ( !body ) { // Return for frameset docs that don't have a body return; } //创建一个container来检测 container = document.createElement("div"); container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; // Check box-sizing and margin behavior. body.appendChild( container ).appendChild( div ); div.innerHTML = ""; // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%"; // Workaround failing boxSizing test due to offsetWidth returning wrong value // with some non-1 values of body zoom, ticket #13543 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() { support.boxSizing = div.offsetWidth === 4; }); // Use window.getComputedStyle because jsdom on node.js will break without it. if ( window.getComputedStyle ) { support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; // Support: Android 2.3 // Check if div with explicit width and no margin-right incorrectly // gets computed margin-right based on width of container. (#3333) // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right marginDiv = div.appendChild( document.createElement("div") ); marginDiv.style.cssText = div.style.cssText = divReset; marginDiv.style.marginRight = marginDiv.style.width = "0"; div.style.width = "1px"; support.reliableMarginRight = !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); } body.removeChild( container ); }); return support;//返回json })( {} );//实参json 本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/6924756.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册