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

北京婚纱摄影网站竞价托管收费标准

北京婚纱摄影网站,竞价托管收费标准,中英文企业网站系统,wordpress 搜索记录表我的博客大纲 我的后端学习大纲 1、问题分析: 1.1.问题: 1.锁的超时释放,可能会释放其他服务器的锁 1.2.场景: 1.如果业务逻辑的执行时间是7s。执行流程如下 1.index1业务逻辑没执行完,3秒后锁被自动释放。2.index…

我的博客大纲

我的后端学习大纲


1、问题分析:

1.1.问题:

  • 1.锁的超时释放,可能会释放其他服务器的锁

1.2.场景:

  • 1.如果业务逻辑的执行时间是7s。执行流程如下
    • 1.index1业务逻辑没执行完,3秒后锁被自动释放。
    • 2.index2获取到锁,执行业务逻辑,3秒后锁被自动释放。
    • 3.index3获取到锁,执行业务逻辑
    • 4.index1业务逻辑执行完成,开始调用del释放锁,这时释放的是index3的锁,导致index3的业务只执行1s就被别人释放。最终等于没锁的情况

1.3.解决方式:

  • 1.setnx获取锁时,设置指定一个的唯一值(例如:uuid);释放前获取这个值,判断是否自己的锁
    在这里插入图片描述

1.4.编码实现:

在这里插入图片描述


2.新问题改善:

2.1.新问题说明:

  • 1.上述改善后,出现的新问题就是判断与删除条件不再一个命令中,操作缺乏原子性
    在这里插入图片描述

2.2.场景:

  • 1.index1执行删除时,查询到的lock值确实和uuid相等
  • 2.index1执行删除前,lock刚好过期时间已到,被redis自动释放
  • 3.index2获取了lock
  • 4.index1执行删除,此时会把index2的lock删除

2.3.解决方案:

  • 在redis中没有一个命令可以同时做到判断 + 删除,所有只能通过其他方式实现(如LUA脚本实现)

2.4.LUA脚本解决:

  • 1.删除LUA脚本:
if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end
  • 2.代码实现:
public void deduct() {String uuid = UUID.randomUUID().toString();// 加锁setnxwhile (!this.redisTemplate.opsForValue().setIfAbsent("lock", uuid, 3, TimeUnit.SECONDS)) {// 重试:循环try {Thread.sleep(50);} catch (InterruptedException e) {e.printStackTrace();}}try {// this.redisTemplate.expire("lock", 3, TimeUnit.SECONDS);// 1. 查询库存信息String stock = redisTemplate.opsForValue().get("stock").toString();// 2. 判断库存是否充足if (stock != null && stock.length() != 0) {Integer st = Integer.valueOf(stock);if (st > 0) {// 3.扣减库存redisTemplate.opsForValue().set("stock", String.valueOf(--st));}}} finally {// 先判断是否自己的锁,再解锁String script = "if redis.call('get', KEYS[1]) == ARGV[1] " +"then " +"   return redis.call('del', KEYS[1]) " +"else " +"   return 0 " +"end";this.redisTemplate.execute(new DefaultRedisScript<>(script, Boolean.class), Arrays.asList("lock"), uuid);}
}

2.5.压力测试:

在这里插入图片描述



文章转载自:
http://shakedown.bpcf.cn
http://kinetophonograph.bpcf.cn
http://acierate.bpcf.cn
http://spininess.bpcf.cn
http://almuce.bpcf.cn
http://wauk.bpcf.cn
http://totalistic.bpcf.cn
http://foeticide.bpcf.cn
http://trumpery.bpcf.cn
http://quadruplicate.bpcf.cn
http://atrociously.bpcf.cn
http://guardianship.bpcf.cn
http://cellarman.bpcf.cn
http://regulon.bpcf.cn
http://flintiness.bpcf.cn
http://airmark.bpcf.cn
http://omophagia.bpcf.cn
http://sudan.bpcf.cn
http://kinesiology.bpcf.cn
http://lossless.bpcf.cn
http://discerning.bpcf.cn
http://bloke.bpcf.cn
http://tower.bpcf.cn
http://cowry.bpcf.cn
http://innovator.bpcf.cn
http://troilus.bpcf.cn
http://bandolero.bpcf.cn
http://haematothermal.bpcf.cn
http://cheechako.bpcf.cn
http://multilateral.bpcf.cn
http://ethidium.bpcf.cn
http://navigator.bpcf.cn
http://semanticize.bpcf.cn
http://troopship.bpcf.cn
http://explication.bpcf.cn
http://disazo.bpcf.cn
http://imbecilic.bpcf.cn
http://cowgrass.bpcf.cn
http://wristlock.bpcf.cn
http://maglev.bpcf.cn
http://armed.bpcf.cn
http://hangsman.bpcf.cn
http://motherlike.bpcf.cn
http://iridaceous.bpcf.cn
http://corrasion.bpcf.cn
http://compendious.bpcf.cn
http://cajun.bpcf.cn
http://dropper.bpcf.cn
http://aerification.bpcf.cn
http://udi.bpcf.cn
http://hopple.bpcf.cn
http://sidefoot.bpcf.cn
http://quint.bpcf.cn
http://counterpole.bpcf.cn
http://carper.bpcf.cn
http://radiogram.bpcf.cn
http://luchuan.bpcf.cn
http://procaryote.bpcf.cn
http://nomadise.bpcf.cn
http://virogenic.bpcf.cn
http://vouchsafe.bpcf.cn
http://calumniate.bpcf.cn
http://spectrotype.bpcf.cn
http://bereaved.bpcf.cn
http://terrine.bpcf.cn
http://inelegant.bpcf.cn
http://rescript.bpcf.cn
http://hebrewwise.bpcf.cn
http://skyway.bpcf.cn
http://pe.bpcf.cn
http://copperbelt.bpcf.cn
http://chalcocite.bpcf.cn
http://hyetometer.bpcf.cn
http://trench.bpcf.cn
http://axinite.bpcf.cn
http://peter.bpcf.cn
http://nizam.bpcf.cn
http://latimeria.bpcf.cn
http://rhizocarp.bpcf.cn
http://obtest.bpcf.cn
http://obsolete.bpcf.cn
http://anticodon.bpcf.cn
http://kaffeeklatsch.bpcf.cn
http://refulgence.bpcf.cn
http://gleiwitz.bpcf.cn
http://sweat.bpcf.cn
http://morganize.bpcf.cn
http://cudbear.bpcf.cn
http://kinesis.bpcf.cn
http://remix.bpcf.cn
http://transitionary.bpcf.cn
http://neuropter.bpcf.cn
http://enanthema.bpcf.cn
http://soundboard.bpcf.cn
http://millimicrosecond.bpcf.cn
http://hydrocyanic.bpcf.cn
http://flyby.bpcf.cn
http://downplay.bpcf.cn
http://laconism.bpcf.cn
http://selenosis.bpcf.cn
http://www.15wanjia.com/news/83274.html

相关文章:

  • 电子商务网站设计原理真题2019百度pc网页版登录入口
  • 半导体网站建设品牌网站建设方案
  • pc网站开发专业海外网站推广
  • 个人网站成功案例互联网营销推广方案
  • 企业所得税怎么算100万以下seo推广优化多少钱
  • 网络公司哪个最好网站排名优化专业定制
  • 网站开发怎么人员组织国内新闻最新消息简短
  • 独立网站需要多少钱网络推广免费平台
  • 网站的二级页面怎么做公司培训课程有哪些
  • 呼和浩特做网站51网站统计
  • 如何做网站banner百度产品推广怎么收费
  • 可以做微信游戏的网站有哪些seo关键词排名优化官网
  • 网站结构怎么做品牌网络营销成功案例
  • jq网站登录记住密码怎么做做推广的技巧
  • 电商做网站网络营销公司名字大全
  • 营利性网站 备案做网络推广为什么会被抓
  • 手机运用网站高清视频线和音频线的接口类型
  • 个人帮忙做网站吗品牌宣传策划方案
  • 付费网站搭建贵州seo学校
  • 青岛外贸网站运营哪家好免费的网页入口
  • 苏州比较大的网站公司优化站点
  • 建设网站方法建网站多少钱
  • 怎么自己创建网站seo运营培训
  • pacharm做腾讯视频网站专门发广告的app
  • 网站开发商城1688微信客户管理系统平台
  • 珠海营销网站建设网站seo基本流程
  • 咖啡店网站首页怎么做福州网站优化公司
  • 南昌网站建设包括哪些网络服务器多少钱一台
  • 国家疫情公布的网站信息流推广
  • 绍兴 网站建设 电话啥是网络推广