一.实现说明

  1. 客户端使用jedis正常set值到redis服务器

    2. 模拟服务器接收jedis发送的信息

二.jedis客户端代码

package com.ahd.redis;

import redis.clients.jedis.Jedis;

public class JedisTest {
public static void main(String[] args) {
Jedis jedis=new Jedis("127.0.0.1"); jedis.set("name","ahdg"); jedis.close();
}
}

三.模拟redis server接收信息并打印

package com.ahd.redis;

  import java.io.IOException;

  import java.io.InputStream;

  import java.net.ServerSocket;

  import java.net.Socket;

  /***

 * 模拟redis服务器

 */

  public class RedisServer {

    public static void main(String[] args) throws IOException {

        //1. 创建服务器对象

        ServerSocket serverSocket=new ServerSocket(6379);

        //2. accept方法

        Socket accept = serverSocket.accept();

        //3. 获取输入流

        InputStream inputStream = accept.getInputStream();

        //4. 将请求的信息转成字符串并打印

        byte[] content=new byte[2048];

        inputStream.read(content);

        System.out.println(new String(content));

    }

}

四.结果分析

可以看出,redis服务端和客户端之间的信息传输是非常简单的,这也是redis性能好的原因之一

redis 模拟redis server接收信息的更多相关文章

  1. 使用Redis模拟简单分布式锁,解决单点故障的问题

    需求描述: 最近做一个项目,项目中有一个功能,每天定时(凌晨1点)从数据库中获取需要爬虫的URL,并发送到对应的队列中,然后客户端监听对应的队列,然后执行任务.如果同时部署多个定时任务节点的话,每个节 ...

  2. [CDH] Redis: Remote Dictionary Server

    基本概念 一.安装 Redis: Remote Dictionary Server 远程字典服务 使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种 ...

  3. python结合redis模拟队列

    实在无聊就写了个很小的python程序用来实现模拟redis队列的代码如下: redis_lpush.py   #!/usr/bin/python3 import time import redis ...

  4. redis 模拟搭建集群

    一.本文是在一台 linux 系统上,模拟搭建 redis 集群.3 台主机,3 台从机. 二.redis 安装步骤 http://www.cnblogs.com/fangwu/p/8602357.h ...

  5. RabbitMQ+Redis模拟手机验证码登录

    RabbitMQ+Redis模拟手机验证码登录 依赖 <dependency> <groupId>org.springframework.boot</groupId> ...

  6. redis配置文件redis.conf参数说明

    redis配置文件redis.conf参数说明 (2013-01-09 21:20:40)转载▼ 标签: redis配置 redis.conf 配置说明 杂谈 分类: nosql # By defau ...

  7. 【Redis】Redis的基本安装及使用

    在Linux上安装Redis Redis的安装很简单.基本上是下载.解压.运行安装脚本.我用的Redis版本是3.2.1. [nicchagil@localhost app]$ wget -q htt ...

  8. redis配置文件redis.conf详细说明

    # By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a ...

  9. 【Redis】Redis学习(六) Redis 基本运维

    Redis的单机搭建,主从搭建,Sentinal搭建,以及Redis集群搭建的步骤参照前面的文章.现在来说一下Redis的基本运维,毕竟如果一切正常是最好的,但是当出现问题不能使用的时候,准确定位问题 ...

随机推荐

  1. 揭秘Android Studio项目目录结构

    I don't know if this is because of the Gradle Build System (I'd wager it is), but I'll tell you what ...

  2. 关于慕课网《使用vue2.0实现购物车和地址选配功能》的总结

    视频学习网址:http://www.imooc.com/learn/796 源码打包:https://codeload.github.com/fachaoshao/Vue-ShoppingCart/z ...

  3. android 播放音乐媒体文件(一)

    Audio formats and codecs Format / Codec Encoder Decoder Details Supported File Type(s) / Container F ...

  4. easyhook报错The given 64-Bit library does not exist

    在调用 RemoteHooking.Inject 时,报错 查看easyhook源代码,出错位置如下 if(!RtlFileExists(UserLibrary)) { #ifdef _M_X64 T ...

  5. Java String.Format() 方法及参数说明

    转自:https://blueram.iteye.com/blog/441683 JDK1.5中,String类新增了一个很有用的静态方法String.format():format(Locale l ...

  6. python接口测试之mock(二)

    上一篇对mock-server已经做了初步的介绍,今天这里继续接着之前的介绍进行,我们先看之前的mock-server部分,之前编写了一个登录的mock,具体json文件见如下的内容: 小王子1110 ...

  7. 【DVWA】Brute Force(暴力破解)通关教程

    日期:2019-08-01 14:49:47 更新: 作者:Bay0net 介绍:一直以为爆破很简单,直到学习了 Burp 的宏录制和匹配关键词,才发现 burp 能这么玩... 0x01. 漏洞介绍 ...

  8. spring/boot 打包,资源/配置/业务文件分离

    spring/boot打包,将业务jar包和资源配置文件进行分离打包,打包后的资源在target/release文件夹下面 注意:添加以下配置后,注意修改自己的入口类 <!--相关编译打包依赖- ...

  9. Golang的面向对象编程【结构体、方法、继承、接口】

    Golang也支持面向对象编程.但与以前学过传统的面向对象编程语言有区别.1)Golang没有类class,Go语言的结构体struct和类class有相似的特性.2)Golang中不存在继承,方法重 ...

  10. python基础语法之字符串

    1 字符串中*的使用 *可以使字符串重复n次 print('hello world ' * 2) # hello world hello world 2 索引获取字符串的字符元素 print('hel ...