Home

OpenResty发送HTTP请求

OpenResty第三方插件lua-resty-http发送HTTP请求 插件GitHub地址https://github.com/ledgetech/lua-resty-http 将插件的http.lua http_connect.lua http_headers.lua三个文件加入openResty的lualib/resty目录中 sendHttp.lua local http = require('resty.http') local httpObj = http.new() local res, err = httpObj:request_uri('http://127.0.0.1:5000/students', { method = 'GET' }) if not...

Read more

OpenResty访问Redis

OpenResty内置redis2-nginx-module访问Redis nginx.conf location /setRedis { default_type text/html; redis2_pass 127.0.0.1:6379; set_unescape_uri $key $arg_key; set_unescape_uri $val $arg_val; redis2_query set $key $val; } location /getRedis { default_type text/html; redis2_pass 127.0.0.1:6379; set_unescape_uri $key $arg_key; ...

Read more

OpenResty运行Lua脚本

代码例子 nginx.conf location /lua { default_type text/html; content_by_lua_file script/helloWorld.lua; } helloWorld.lua ngx.say("<h1>Hello, world!</h1>");

Read more

Elasticsearch客户端Java High Level REST Client使用

前言 Java High Level REST Client在Elasticsearch 7.15版本后官方不再建议使用,在Elasticsearch 8.x版本中兼容模式下可以使用Java High Level REST Client的7.17版本 Elasticsearch 7.15版本以后,官方推荐使用Java API Client 基础API 客户端连接 RestHighLevelClient esClient = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http"))); esClient.close(); 创建Index CreateIndexRe...

Read more

Elasticsearch基本使用

Elasticsearch与关系型数据库概念类比 Index -> Database Type -> Table (7以上版本概念删除) Document -> Row Field -> Column Elasticsearch基础操作 创建Index PUT http://localhost:9200/shopping 获取Index信息 GET http://localhost:9200/shopping GET http://localhost:9200/_cat/indices?v 删除Index DELETE http://localhost:9200/shopping 创建Document POST ht...

Read more

Redis运行Lua脚本

直接运行Lua脚本 eval "return 1+1" 0 传参数 eval "local msg = 'hello:' return msg..ARGV[1]" 1 name aaa 运行文件脚本 eval test.lua 0 脚本管理,重启后缓存的脚本会消失 script load "$(cat test.lua)" evalsha "a27e7e8a43702b7046d4f6a7ccf5b60cef6b9bd9" 0 Lua脚本访问Redis count.lua local count = 0 local redisCount = redis.call('get', 'count') if redisCount then count = redi...

Read more

Java栈与队列的实现

栈和队列的实现 实现类使用实现了Deque接口的类,如ArrayQueue或LinkedList,性能上ArrayQueue占优 栈的实现 使用Deque接口,ArrayDeque实现类 Deque<String> stack = new ArrayDeque<>(); stack.push("a"); stack.push("b"); stack.push("c"); while (stack.peek() != null) { System.out.println(stack.pop()); } 输出结果 c b a 队列的实现 使用Queue接口,ArrayDeque实现类 add和remove方法,失败抛异常 Queue&...

Read more

Nginx配置

配置文件结构 修改conf/nginx.conf # main块 # events块 events { } # http块 http { # 支持多个server块 server { # 支持多个location块 location / { } } } 核心配置 main块,全局配置 # 是否以守护进程方式运行,默认开启 daemon on; # 工作进程数,可以对应CPU核心数,设置为auto将匹配CPU核心数,默认值为1 worker_processes 8; # 配置主进程pid存放位置 pid logs/nginx.pid events块,服务器与客户端的网络连接相关配置 event...

Read more

RabbitMQ在Docker下安装

RabbitMQ安装 docker run -p 15672:15672 -p 5672:5672 --name rabbitmq \ --restart always \ -v /etc/timezone:/etc/timezone:ro \ -v /etc/localtime:/etc/localtime:ro \ -d rabbitmq:3.8-management 配置root用户 docker exec -it rabbitmq /bin/bash rabbitmqctl add_user root rabbitmqroot rabbitmqctl set_permissions -p / root ".*" ".*" ".*" rabbitmqctl set_us...

Read more

Set的内部排序

知识总结 实现SortedSet接口的类,例如TreeSet,ConcurrentSkipListSet。Set内的元素以元素的比较规则保持有序,元素需要实现Comparable接口 LinkedHashSet和CopyOnWriteArraySet,可以保持元素加入Set时的顺序 HashSet则无法保持任何顺序

Read more