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

redis做网站统计wordpress主题插件下载

redis做网站统计,wordpress主题插件下载,龙岗网站建设公司哪家口碑好,百度号码认证平台首页Redis限流插件-redis-cell redis-cell 是一个用rust语言编写的基于令牌桶算法的的限流模块#xff0c;提供原子性的限流功能#xff0c;并允许突发流量#xff0c;可以很方便的应用于分布式环境中。 下载redis-cell插件 访问Releases brandur/redis-cell (github.com) 上传…Redis限流插件-redis-cell redis-cell 是一个用rust语言编写的基于令牌桶算法的的限流模块提供原子性的限流功能并允许突发流量可以很方便的应用于分布式环境中。 下载redis-cell插件 访问Releases · brandur/redis-cell (github.com) 上传redis-cell插件到linux服务器 解压插件 [rootlocalhost plugin]# tar -zxvf redis-cell-v0.3.1-x86_64-unknown-linux-gnu.tar.gz libredis_cell.d libredis_cell.so拷贝libredis_cell.so到redis容器中 docker cp libredis_cell.so redis_6390:/usr/local/etc/redis修改后redis.conf文件 在redis.conf配置文件中引用插件 38 ################################## MODULES ##################################### 39 40 # Load modules at startup. If the server is not able to load modules 41 # it will abort. It is possible to use multiple loadmodule directives. 42 # 43 # loadmodule /path/to/my_module.so 44 loadmodule /usr/local/etc/redis/libredis_cell.so插件使用 查询插件是否已启用 输入命令: module list 127.0.0.1:6379 module list 1) 1) name2) redis-cell3) ver4) (integer) 1语法 127.0.0.1:6379 cl.throttle mytest 99 5 100 2 1) (integer) 0 #0 表示成功 1表示失败 2) (integer) 100 # 令牌桶的容量 3) (integer) 98 # 当前令牌桶的令牌数 4) (integer) -1 # 成功时该值为-1失败时表还需要等待多少秒可以有足够的令牌 5) (integer) 41 # 预计多少秒后令牌桶会满测试 多次从令牌桶取出数据 127.0.0.1:6379 cl.throttle mytest 99 5 100 40 1) (integer) 0 2) (integer) 100 3) (integer) 54 4) (integer) -1 5) (integer) 911 127.0.0.1:6379 cl.throttle mytest 99 5 100 40 1) (integer) 0 2) (integer) 100 3) (integer) 14 4) (integer) -1 5) (integer) 1708 127.0.0.1:6379 cl.throttle mytest 99 5 100 40 1) (integer) 1 #失败拒绝取出 2) (integer) 100 3) (integer) 14 4) (integer) 505 # 取出失败令牌桶还有14个令牌还需505秒才能够取出 5) (integer) 1705springboot使用令牌 引入redis dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId /dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactId /dependencyyml配置 server:port: 10022 spring:redis:host: 192.168.198.128port: 6390redis配置 package com.wnhz.redis.config;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;Configuration public class RedisConfig {Beanpublic RedisTemplateString,Object redisTemplate(RedisConnectionFactory factory){RedisTemplateString,Object redisTemplate new RedisTemplate();redisTemplate.setConnectionFactory(factory);redisTemplate.setKeySerializer(new StringRedisSerializer());redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());redisTemplate.setHashKeySerializer(new StringRedisSerializer());redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());return redisTemplate;} }测试 PostMapping(/redisCell)public String redisCell() {String script return redis.call(cl.throttle,KEYS[1],ARGV[1],ARGV[2],ARGV[3],ARGV[4]);DefaultRedisScriptListLong defaultRedisScript new DefaultRedisScript();int maxBurst 99;int countPerPeriod 10;int period 100;int quantity 10;ListLong retVal redisTemplate.execute(new DefaultRedisScript(script, List.class),new ArrayListString() {{add(cell_key);}},maxBurst,countPerPeriod,period,quantity);System.out.println(retVal);if (1 retVal.get(0)) { //第一个返回为1,表示拒绝return 频繁访问服务器过载请过一会再来;}return SUCCESS;}运行结果 [0, 100, 90, -1, 101] redis-cell封装 /*** param key redis key* param maxBurst 令牌桶最大容量* param countPerPeriod 通过的令牌桶数(countPerPeriod/period 速率)* param period 时间* param quantity 取出数量* return List 返回集合中5个Long值* 第0个位置: 0 表示成功 1表示失败* 第1个位置: 令牌桶的容量* 第2个位置: 当前令牌桶的令牌数* 第3个位置: 成功时该值为-1失败时表还需要等待多少秒可以有足够的令牌* 第4个位置: 预计多少秒后令牌桶会满*/ public ListLong redisCell(String key,String maxBurst,String countPerPeriod,String period,String quantity) {final String script return redis.call(cl.throttle,KEYS[1],ARGV[1],ARGV[2],ARGV[3],ARGV[4]);connect();ListLong eval this.connection.sync().eval(script, ScriptOutputType.MULTI,new String[]{key},maxBurst,countPerPeriod,period,quantity);returnPool();return eval; }
http://www.zqtcl.cn/news/653840/

相关文章:

  • 百度速页建站wordpress审核插件
  • 怎么给网站wordpress专业的vi设计公司
  • 百度关键词在线优化寻找郑州网站优化公司
  • 网站建设适合什么单位网络推广员工作内容
  • 漂亮的网站维护页面wordpress加个微信登录
  • 网站设计是什么意思创建地址怎么弄
  • nas上建设网站文章网站哪里建设好
  • 消防网站模板广告设计专业需要学什么
  • 建设银行网站首页wordpress 登录函数
  • 做网站多长时间广州营销网站制作
  • 美团外卖网站开发建设网站如何写文案
  • 专门做画册封面的网站开发工程师网站开发工程师招聘
  • 广州市建设局网站自己做电影网站违法
  • 网站建设首选公司大丰专业做网站
  • 用dw怎么做网站辽宁省住房和城乡建设厅网站首页
  • 如何用微信小程序做网站2个网站做的链接怎么用一个域名
  • 大理网站建设滇icp备凡科网站代码如何修改
  • 做电商网站的公司简介网站制作多久
  • 营销手段有哪些方式合肥网站优化服务网
  • 网站备案和域名备案山东临沂市建筑模板生产厂家
  • 三类安全员证查询系统网站建设优化服务机构
  • 网站关键词排名没有了城固县网站建设
  • 什么网站需要备案易语言用电脑做网站服务器
  • 可以做婚礼鲜花布置的网站洛阳霞光企业网站建设公司
  • 临淄网站制作同步显示一个wordpress
  • 先建设网站后付款网站相对路径和绝对路径
  • 临沂外贸国际网站建设网站开发外包公司合同
  • 网站设置快捷方式温州网站建设方案报价
  • 经营网站需要什么费用如何鉴赏网站论文
  • 聊城网站推广公司网站 防攻击