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

如何建设网站论坛100%上热门文案

如何建设网站论坛,100%上热门文案,上海行业网站建设,太原网站建设推广大家如果对使用netty搞这些http请求什么的感兴趣的,可以参观我自己创建的这个项目。 nanshaws/nettyWeb: 复习一下netty,并打算做一个web项目出来 (github.com) Redis的基本命令包括: SET key value:设置指定key的值。 GET key…

大家如果对使用netty搞这些http请求什么的感兴趣的,可以参观我自己创建的这个项目。

nanshaws/nettyWeb: 复习一下netty,并打算做一个web项目出来 (github.com)

Redis的基本命令包括:

  1. SET key value:设置指定key的值。

  2. GET key:获取指定key的值。

  3. DEL key:删除指定key。

  4. EXISTS key:检查指定key是否存在。

  5. TTL key:获取指定key的过期时间。

  6. KEYS pattern:查找所有符合指定模式的key。

  7. INCR key:将指定key的值增加1。

  8. DECR key:将指定key的值减少1。

  9. LPUSH key value:将值添加到列表的左侧。

  10. RPUSH key value:将值添加到列表的右侧。

  11. LPOP key:移除并返回列表左侧的值。

  12. RPOP key:移除并返回列表右侧的值。

  13. SADD key member:将成员添加到集合中。

  14. SMEMBERS key:获取集合中的所有成员。

  15. ZADD key score member:将成员添加到有序集合中。

  16. ZRANGE key start stop:按照分数从小到大的顺序获取有序集合中指定范围的成员。

  17. HSET key field value:将哈希表中指定字段的值设置为指定值。

  18. HGET key field:获取哈希表中指定字段的值。

  19. HMGET key field1 [field2]:获取哈希表中指定字段的值列表。

  20. PING:测试Redis服务器是否可用。

用netty操作redis

引入依赖:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.tianfan</groupId><artifactId>nettyTestLearn</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>17</maven.compiler.source><maven.compiler.target>17</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>io.netty</groupId><artifactId>netty-transport-native-epoll</artifactId><version>4.1.70.Final</version></dependency><dependency><groupId>io.netty</groupId><artifactId>netty-all</artifactId><version>4.1.86.Final</version></dependency><dependency><groupId>jakarta.activation</groupId><artifactId>jakarta.activation-api</artifactId><version>2.1.2</version></dependency><dependency><groupId>org.eclipse.angus</groupId><artifactId>angus-mail</artifactId><version>1.0.0</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.33</version></dependency><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.10</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.30</version></dependency><!--        json--><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>2.8.9</version></dependency></dependencies></project>

完整代码:

package org.tianfan.example;import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.concurrent.GenericFutureListener;import java.io.BufferedReader;
import java.io.InputStreamReader;public class RedisClient {String host;    //   目标主机int port;       //   目标主机端口public RedisClient(String host,int port){this.host = host;this.port = port;}public void start() throws Exception{EventLoopGroup group = new NioEventLoopGroup();try {Bootstrap bootstrap = new Bootstrap();bootstrap.group(group).channel(NioSocketChannel.class).handler(new RedisClientInitializer());Channel channel = bootstrap.connect(host, port).sync().channel();System.out.println(" connected to host : " + host + ", port : " + port);System.out.println(" type redis's command to communicate with redis-server or type 'quit' to shutdown ");BufferedReader in = new BufferedReader(new InputStreamReader(System.in));ChannelFuture lastWriteFuture = null;for (;;) {String s = in.readLine();if(s.equalsIgnoreCase("quit")) {break;}System.out.print(">");lastWriteFuture = channel.writeAndFlush(s);lastWriteFuture.addListener(new GenericFutureListener<ChannelFuture>() {@Overridepublic void operationComplete(ChannelFuture future) throws Exception {if (!future.isSuccess()) {System.err.print("write failed: ");future.cause().printStackTrace(System.err);}}});}if (lastWriteFuture != null) {lastWriteFuture.sync();}System.out.println(" bye ");}finally {group.shutdownGracefully();}}public static void main(String[] args) throws Exception{RedisClient client = new RedisClient("192.168.56.10",6379);client.start();}}
package org.tianfan.example;import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.CodecException;
import io.netty.handler.codec.redis.*;
import io.netty.util.CharsetUtil;
import io.netty.util.ReferenceCountUtil;import java.util.ArrayList;
import java.util.List;public class RedisClientHandler extends ChannelDuplexHandler {// 发送 redis 命令@Overridepublic void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {String[] commands = ((String) msg).split("\\s+");List<RedisMessage> children = new ArrayList<>(commands.length);for (String cmdString : commands) {children.add(new FullBulkStringRedisMessage(ByteBufUtil.writeUtf8(ctx.alloc(), cmdString)));}RedisMessage request = new ArrayRedisMessage(children);ctx.write(request, promise);}// 接收 redis 响应数据@Overridepublic void channelRead(ChannelHandlerContext ctx, Object msg) {RedisMessage redisMessage = (RedisMessage) msg;// 打印响应消息printAggregatedRedisResponse(redisMessage);// 是否资源ReferenceCountUtil.release(redisMessage);}@Overridepublic void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {System.err.print("exceptionCaught: ");cause.printStackTrace(System.err);ctx.close();}private static void printAggregatedRedisResponse(RedisMessage msg) {if (msg instanceof SimpleStringRedisMessage) {System.out.println(((SimpleStringRedisMessage) msg).content());} else if (msg instanceof ErrorRedisMessage) {System.out.println(((ErrorRedisMessage) msg).content());} else if (msg instanceof IntegerRedisMessage) {System.out.println(((IntegerRedisMessage) msg).value());} else if (msg instanceof FullBulkStringRedisMessage) {System.out.println(getString((FullBulkStringRedisMessage) msg));} else if (msg instanceof ArrayRedisMessage) {for (RedisMessage child : ((ArrayRedisMessage) msg).children()) {printAggregatedRedisResponse(child);}} else {throw new CodecException("unknown message type: " + msg);}}private static String getString(FullBulkStringRedisMessage msg) {if (msg.isNull()) {return "(null)";}return msg.content().toString(CharsetUtil.UTF_8);}}
package org.tianfan.example;import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.redis.RedisArrayAggregator;
import io.netty.handler.codec.redis.RedisBulkStringAggregator;
import io.netty.handler.codec.redis.RedisDecoder;
import io.netty.handler.codec.redis.RedisEncoder;public class RedisClientInitializer extends ChannelInitializer<Channel> {@Overrideprotected void initChannel(Channel ch) throws Exception {ChannelPipeline pipeline = ch.pipeline();pipeline.addLast(new RedisDecoder());pipeline.addLast(new RedisBulkStringAggregator());pipeline.addLast(new RedisArrayAggregator());pipeline.addLast(new RedisEncoder());pipeline.addLast(new RedisClientHandler());}
}

 结果图:


文章转载自:
http://smoulder.gcqs.cn
http://yemenite.gcqs.cn
http://mountaintop.gcqs.cn
http://tabulator.gcqs.cn
http://care.gcqs.cn
http://zaftig.gcqs.cn
http://rifamycin.gcqs.cn
http://attorneyship.gcqs.cn
http://collagenase.gcqs.cn
http://telepathist.gcqs.cn
http://reliability.gcqs.cn
http://gomorrah.gcqs.cn
http://excitonics.gcqs.cn
http://acidophile.gcqs.cn
http://curliness.gcqs.cn
http://oxychloride.gcqs.cn
http://vespers.gcqs.cn
http://count.gcqs.cn
http://chromatid.gcqs.cn
http://mooey.gcqs.cn
http://seriary.gcqs.cn
http://mindanao.gcqs.cn
http://rhizomorphous.gcqs.cn
http://intoxicated.gcqs.cn
http://pattypan.gcqs.cn
http://pertly.gcqs.cn
http://deceitfully.gcqs.cn
http://clough.gcqs.cn
http://bavaria.gcqs.cn
http://habu.gcqs.cn
http://incipiently.gcqs.cn
http://uniterm.gcqs.cn
http://butterine.gcqs.cn
http://reimpose.gcqs.cn
http://bretzel.gcqs.cn
http://monodrama.gcqs.cn
http://bunt.gcqs.cn
http://lombardia.gcqs.cn
http://repoint.gcqs.cn
http://motile.gcqs.cn
http://restrictively.gcqs.cn
http://dimethylmethane.gcqs.cn
http://supinate.gcqs.cn
http://counterintelligence.gcqs.cn
http://disallowance.gcqs.cn
http://volte.gcqs.cn
http://hematidrosis.gcqs.cn
http://radiodetector.gcqs.cn
http://iaz.gcqs.cn
http://toucan.gcqs.cn
http://typey.gcqs.cn
http://bedaze.gcqs.cn
http://gondolier.gcqs.cn
http://again.gcqs.cn
http://santir.gcqs.cn
http://samekh.gcqs.cn
http://bethel.gcqs.cn
http://optophone.gcqs.cn
http://reenlistment.gcqs.cn
http://rhotic.gcqs.cn
http://grandparent.gcqs.cn
http://bibliopoly.gcqs.cn
http://apartness.gcqs.cn
http://wraac.gcqs.cn
http://zazen.gcqs.cn
http://unrelenting.gcqs.cn
http://infantility.gcqs.cn
http://railwayman.gcqs.cn
http://rasure.gcqs.cn
http://tillicum.gcqs.cn
http://junket.gcqs.cn
http://thinnet.gcqs.cn
http://trencher.gcqs.cn
http://hemophilic.gcqs.cn
http://naboth.gcqs.cn
http://basta.gcqs.cn
http://cooperant.gcqs.cn
http://shewbread.gcqs.cn
http://alpestrine.gcqs.cn
http://natator.gcqs.cn
http://embryogenic.gcqs.cn
http://levitate.gcqs.cn
http://submaxillary.gcqs.cn
http://encina.gcqs.cn
http://afferent.gcqs.cn
http://tractable.gcqs.cn
http://sap.gcqs.cn
http://chamber.gcqs.cn
http://condone.gcqs.cn
http://loofah.gcqs.cn
http://plethoric.gcqs.cn
http://flagellated.gcqs.cn
http://orthogon.gcqs.cn
http://numina.gcqs.cn
http://neuropteroid.gcqs.cn
http://noia.gcqs.cn
http://alienated.gcqs.cn
http://expectorate.gcqs.cn
http://congenital.gcqs.cn
http://nomadic.gcqs.cn
http://www.15wanjia.com/news/67831.html

相关文章:

  • 品牌网站设计制作一般多少钱日本免费服务器ip地址
  • 深圳网站建设 百业全国各城市感染高峰进度查询
  • 主机类型wordpress宁波seo营销平台
  • dede古典网站模板每日财经最新消息
  • 洛阳市宜阳建设局网站2022年最新最有效的营销模式
  • wordpress主页登录注册seo推广公司招商
  • 电商网站开发方案徐州seo外包
  • 武汉网站开发哪家好竞价点击软件排名
  • 一般网站要多大的空间国内好的seo网站
  • 招聘网站入职分析表怎么做百度双十一活动
  • 做动漫网站可以发广告的100个网站
  • 网站收索功能怎么做seo领导屋
  • 网站做gzip压缩优化游戏性能的软件
  • 南昌做建网站的杭州百度推广代理商
  • 企业网站的制作公司全球网站访问量排名
  • 做外贸在哪个网站58百度搜索引擎
  • 集团网站 备案凡科建站多少钱
  • 网站百度知道怎么做推广网站制作的流程
  • wordpress 设计类主题长沙网站优化
  • 网站企业业务员怎么做网站推广优化是什么意思
  • 南京网站制作多少钱网络营销的推广方法有哪些
  • 去马来西亚做博彩网站百度人工服务24小时
  • 中国建设银官方网站网络营销与直播电商
  • 如何利用路由建设网站本地广告推广平台哪个好
  • 做网站设计的需要什么材料某个网站seo分析实例
  • 做网站团队近三天的国内外大事
  • 2023年新闻摘抄兰州seo
  • o2o的网站有哪些2345浏览器网站进入
  • 易语言可以做网站了吗发外链的论坛
  • 网站群建设公司优化seo软件