用lua+redis实现一个简单的计数器功能 (二)
环境已经搭建完毕 传送门
- 计数方案
就目前来看nginx是最快的服务
我在设计方案时选择信任redis作为存储库,不做穿透处理,由于目前redis集群方案还不成熟,只在这里做了主备方案。想做集群方案的人可以考虑使用twemproxy
--如采用twemproxy 集群方案 不要选择信任redis集群,最好有穿透机制 一旦某机器当机,恢复会很麻烦
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAArAAAAGQCAIAAADZYsRKAAAgAElEQVR4nO3d729TZ57///wxzD9hcePMVFvtppEPjJaCtCt6pPjGam7s5GgibrTRSmdGrKg0U7uSbyHVrpZSbti5QfcWBwkokQ6qhOaGDZQUVXE6rQnYTpuG1sdQON8b7y/Xx2vHVxPb55f9fNyYHuwTxznJ9b5eedkwC7lczsAIuVwuAACkHDudhtrpFgzDiPf7lGRcHABIu42NjbW1tbifRUL1X5wFwzBeYQTDMJrNZqvVivcbBgAYWy6X++qrr+LeTxIql8vduXOn2Wy2220CgY4EgmazGffPMwBgHPIbcNybSULdvn17dXVVtrm9vT0CgQ6BAABSjXpAQ9UDT548efny5YJhGC8xAoEAANJrY2Pjvffei3snSaiBeiCQ9xDE/aySi0AAAOmVy+U2Nzfj3kkSaqAeCAgEegQCAEgp6gGN4XogIBDoEQgAIKWoBzSG64FAAsEvGIFAAABpJPVA3HtIQn3++efD9UBAINAjEABAGkk9EPceklDLy8vD9UBAINAjEABA6lAPaIyqBwICgR6BAABSh3pAY1Q9EEggeIERCAQAkC5SD8S9eyTUrVu3RtUDAYFAj0AAAOmSy+UePnwY9+6RUJp6ICAQ6BEIACBFHj16tLy8HPfWkVAPHz585513RtUDgQSC5xiBQAAAKbK2tnbr1q24t46Eevfddz/77LNms/n06dPheiAgEOgRCAAgLaQeiHvfSKgvv/xS1QPPnj078AISCHQIBACQFtQDGqoeePLkyatXrw68gAQCHQIBAKQC9YDGYeqBQAJBDyMQCAAgFdbW1m7evBn3ppFQh6kHAgKBHoEAAJJP6oG4d4yEevDgwWHqg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sDzPNd15TR1gjxUtVp1HEdVC2EgEAAA5kRYgUBeKZCqwPf9QqFQLpf7T5DjX20I5BFc11UfrpTLZcuybNtuNBrT/RIUAgEAYE6EFQik1fd93zRN3/f7CwDXdfWBQN5DYFmWPI70Af2P4Hme4zhSLTQaDcuypFSQ8DFFBAIAwJyYfiAoFAqyMWcyGd/3TdPsf0eh7/vS8zuO4ziOaZrqQO5tNBoD7yGQB5SGoN1uu64rUcC2bXnpoVAouK479TTg+74RgqWlpbi/6QAADJp+IFB7v3rVf+BNf/2v+g83BOoFBRUIpC0Y/kTqRsdxVOUwXWE0BAAAJNCCYRjdqXIcZ+CWfD7f7XZLpdLwCepYHajTVlZWJBBUKhXHceRBlFKpVKlU1JnT/RIUAgEAYE5MORB4nre1tZXP552D1Gq1SqXSarXU+ZID8vl8JpORW65duya3y3sIHMfZ2trqdrulUkllhVKpJKfVajXLsrLZ7BS/hH4EAgDAnJh+QzBLCAQAgDlBINAhEAAA5sSCYRg/YwQCAQBgThAIdAgEAIA5QSDQIRAAAObEgmEYP2EEAgEAYE4QCHQIBACAOUEg0CEQAADmBIFAh0AAAJgTC4ZhPMMIBAIAwJwgEOgQCAAAc4JAoEMgAADMCQKBDoEAADAnFgzD2McIBAIAwJwgEOgQCAAAc4JAoEMgAADMiQXDMH7ECAQCAMCcIBDoEAgAAHOCQKBDIAAAzAkCgQ6BAAAwJxYMw9jDCAQCAMCcIBDoEAgAAHOCQKBDIAAAzAkCgQ6BAAAwJxaWlpYMjLC4uEggAADMgwX5TxNa8X6TAAAI2/8fCHZ2duLec5NrZ2cn3m8SAABh+/8A4RQLsugEUN4AAAAASUVORK5CYII=" alt="" />
- 程序部分
为方便管理lua文件,修改nginx.conf并重启
lua_package_path '/var/www/lib/?.lua';
lua_package_cpath '/usr/local/nginx/so/?.so'; #加载动态库
init_by_lua_file '/usr/local/nginx/lua/init.lua';#将配置文件加载到nginx内存中
lua_shared_dict config 45m;//配置内存大小
include site/*.conf;
新建site/lua.conf
server {
listen ;
server_name count.xxxxxx.com; location ^~/user_group_praise/ {
access_log off;
lua_code_cache off;
content_by_lua_file /usr/local/nginx/lua/count.lua;
}
}
init.lua代码让配置文件常驻内存
local cjson = require "cjson"; local config = ngx.shared.config; local file = io.open("/usr/local/nginx/lua/count.cjson", "r");
local content = cjson.decode(file:read("*all"));
file:close(); for name, value in pairs(content) do
config:set(name, cjson.encode(value));
end
count.cjson
{
"user_group_praise": {
"redis_host": "127.0.0.1",
"redis_port": ,
"cv_key": "user_praise",
"key": [
"uid"
],
"count_name": "用户直通赞数"
}
}
count.lua代码
ngx.header.content_type = "text/plain;charset=utf-8" local request_method = ngx.var.request_method
local args = nil
if "GET" == request_method then
args = ngx.req.get_uri_args()
elseif "POST" == request_method then
ngx.req.read_body()
args = ngx.req.get_post_args()
end local uri = ngx.var.uri;
uri = string.sub(uri,,#uri);
local uripos = string.find(uri , '/');
if(uripos == null) then
ngx.say('{"errorCode":500,"errorMsg":"'..conf_tab['count_name']..' 参数错误}');
ngx.exit(); end
local type = string.sub(uri , ,uripos-);
local functionname = string.sub(uri , uripos+ ,#uri); local cjson = require "cjson";
local config = ngx.shared.config; local conf_tab = config:get(type);
if(conf_tab == null) then
ngx.say('{"errorCode":500,"errorMsg":"'..conf_tab['count_name']..' 无此计数类型}');
ngx.exit();
end
conf_tab = cjson.decode(conf_tab); local param_key_all = '';
--检测参数
if(functionname ~= 'get') then param_key_all = param_key_all..conf_tab['cv_key']; for key, val in pairs(conf_tab['key']) do
if(args[val] == null) then
ngx.say('{"errorCode":500,"errorMsg":"'..conf_tab['count_name']..' 参数错误}');
ngx.exit();
end
param_key_all = param_key_all..':'..args[val];
end else
if(args['json'] == null) then
ngx.say('{"errorCode":500,"errorMsg":"'..conf_tab['count_name']..' 参数错误}');
ngx.exit();
end
local param_tab = cjson.decode(args['json']);
if(param_tab == null) then
ngx.say('{"errorCode":500,"errorMsg":"'..conf_tab['count_name']..' 参数错误}');
ngx.exit();
end for key, val in pairs(param_tab) do
param_key_all = param_key_all..','.."'"..conf_tab['cv_key']; for i=,#conf_tab['key'], do
if(val[conf_tab['key'][i]] == null) then
ngx.say('{"errorCode":500,"errorMsg":"'..conf_tab['count_name']..' 参数错误}');
ngx.exit();
end
param_key_all = param_key_all..':'..val[conf_tab['key'][i]];
end
param_key_all = param_key_all.."'";
end
param_key_all = string.sub(param_key_all,,#param_key_all); end
local redis = require("resty.redis");
local red = redis:new();
red:set_timeout(); -- 1 sec
local ok, err = red:connect(conf_tab['redis_host'] , conf_tab['redis_port'] );
if not ok then
ngx.say('{"errorCode":500,"errorMsg":"'..conf_tab['count_name']..' REDIS服务器连接错误}')
ngx.exit();
end if(functionname == 'get') then
local cvval = red:eval("return redis.call('mget',"..param_key_all..")",);
local results = {};
results['data'] = cvval;
results['errorCode'] = ;
results['errorMsg'] = 'ok'; ngx.say(cjson.encode(results));
elseif(functionname == 'inc') then
cnum=red:incrby(param_key_all,)
ngx.say('{"errorCode":0,"errorMsg":"ok","data":'..cnum..'}')
elseif(functionname == 'dec') then
cnum=red:incrby(param_key_all,-);
ngx.say('{"errorCode":0,"errorMsg":"ok","data":'..cnum..'}')
elseif(functionname == 'clear') then
cnum=red:set(param_key_all,);
ngx.say('{"errorCode":0,"errorMsg":"ok","data":0}')
else
ngx.say('参数错误'); end
red:set_keepalive(, );
用lua+redis实现一个简单的计数器功能 (二)的更多相关文章
- 用lua+redis实现一个简单的计数器功能 (一)
首先安装环境 依赖环境有 luajit http://luajit.org ngx_devel_kit https://github.com/simpl/ngx_devel_kit echo-ngin ...
- 180626-Spring之借助Redis设计一个简单访问计数器
文章链接:https://liuyueyi.github.io/hexblog/2018/06/26/180626-Spring之借助Redis设计一个简单访问计数器/ Spring之借助Redis设 ...
- Python使用Redis实现一个简单作业调度系统
Python使用Redis实现一个简单作业调度系统 概述 Redis作为内存数据库的一个典型代表,已经在非常多应用场景中被使用,这里仅就Redis的pub/sub功能来说说如何通过此功能来实现一个简单 ...
- java实现一个简单的计数器
package com.fengunion.sf; import org.junit.platform.commons.util.StringUtils; import java.util.HashM ...
- 手把手教你用redis实现一个简单的mq消息队列(java)
众所周知,消息队列是应用系统中重要的组件,主要解决应用解耦,异步消息,流量削锋等问题,实现高性能,高可用,可伸缩和最终一致性架构.目前使用较多的消息队列有 ActiveMQ,RabbitMQ,Zero ...
- JS事件 编程练习-自制计算器 使用JS完成一个简单的计算器功能。实现2个输入框中输入整数后,点击第三个输入框能给出2个整数的加减乘除。
编程练习 使用JS完成一个简单的计算器功能.实现2个输入框中输入整数后,点击第三个输入框能给出2个整数的加减乘除. 提示:获取元素的值设置和获取方法为:例:赋值:document.getElement ...
- PHP + Redis 实现一个简单的twitter
原文位于Redis官网http://redis.io/topics/twitter-clone Redis是NoSQL数据库中一个知名数据库,在新浪微博中亦有部署,适合固定数据量的热数据的访问. 作为 ...
- SpringBoot学习笔记(13)----使用Spring Session+redis实现一个简单的集群
session集群的解决方案: 1.扩展指定server 利用Servlet容器提供的插件功能,自定义HttpSession的创建和管理策略,并通过配置的方式替换掉默认的策略.缺点:耦合Tomcat/ ...
- 原生js实现一个简单的倒计时功能
大家好,我是云中君!欢迎大家来观看我的博客 之前那,在群里看到很多人问,关于电商网站中的倒计时功能怎么实现,很多人说在网上找了很多插件,但是不是很会用,所以今天就在这里分享一下我封装的一个小的倒计时功 ...
随机推荐
- Akka(31): Http:High-Level-Api,Route rejection handling
Route 是Akka-http routing DSL的核心部分,使用户能比较方便的从http-server的角度筛选http-request.进行server运算.构建回复的http-respon ...
- 使用clone
1.继承Cloneable接口 2.重写clone方法 3.在clone方法中调用super.clone() 4.把浅复制的引用指向原型对象新的克隆体
- Git相关操作一
1.将目录变为Git项目: 输入git init将当期目录变为Git项目 git init git项目可以被认为分为三个区域,Working Directory,Staging Area,Reposi ...
- LeetCode 259. 3Sum Smaller (三数之和较小值) $
Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 < ...
- java swing中Timer类的学习
最近在完成学校课程的java平时作业,要实现一个计时器,包含开始.暂停以及重置三个功能.由于老师规定要用这个timer类,也就去学习了一下,顺便记录一下. 首先呢去查了一下java手册上的东西,发现t ...
- Windows环境下多线程编程原理与应用读书笔记(1)————基本概念
自从学了操作系统知识后,我就对多线程比较感兴趣,总想让自己写一些有关多线程的程序代码,但一直以来,发现自己都没怎么好好的去全面学习这方面的知识,仅仅是完成了操作系统课程上的小程序,对多线程的理解也不是 ...
- Caused by: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException):
用windows连接hadoop集群执行mapreduce任务的时候出现以下错误: org.apache.hadoop.security.AccessControlException:Permissi ...
- no device found for connection ‘ System eth0′问题
我用的是centos6 在ping 百度的时候ping不通 提示错误no device found for connection ' System eth0′ 解决方法:虚拟机右上角有一个小电脑的标志 ...
- 小米Java程序员第二轮面试10个问题,你是否会被刷掉?
近日,开发者头条上分享了一篇"小米java第二轮面经",有很多的java程序员表示非常有兴趣. 下面l就和各位分享小米java第二轮面经(华为java工程师笔试面试题可以看文章某尾 ...
- linux分析日志的一些常用方法
head -n 2016_05_23_access_log |grep "/859" 显示前10000行中包含 /859 的记录 增加 |wc -l 则改为输出记录数 cat 2 ...