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

杭州江干建设局网站宁波百度seo排名优化

杭州江干建设局网站,宁波百度seo排名优化,做网站最清晰的字体,软件开发工具与平台随着业务发展的需要,原单体单机部署的系统被演化成分布式集群系统后,由于分布式系统多线程、多进程并且分布在不同机器上,这将使原单机部署情况下的并发控制锁策略失效,单纯的 Java API并不能提供分布式锁的能力。为了解决这个问题…

随着业务发展的需要,原单体单机部署的系统被演化成分布式集群系统后,由于分布式系统多线程、多进程并且分布在不同机器上,这将使原单机部署情况下的并发控制锁策略失效,单纯的 Java API并不能提供分布式锁的能力。为了解决这个问题就需要一种跨 JVM 的互斥机制来控制共享资源的访问,这就是分布式锁要解决的问题!
分布式锁主流的实现方案:
1.基于数据库实现分布式锁.
2.基于缓存( Redis等)
3基于 Zookeeper*
每一种分布式锁解决方案都有各自的优缺点:
下面简单记录一下redis的简单方法。
1.redis设置锁

//设置锁
setnx [key] [value]
//删除
del [key]

再次设置对应值会设置失败
在这里插入图片描述
2.避免锁长时间未释放,设置过期时间

expire [key]  [second]

3.同时上锁和设置过期时间

set [key] [value] nx  ex [s]

在这里插入图片描述
4.解决redis原子性的问题,可以使用lua脚本进行锁的释放。
代码简单实现如下

package com.chd.jot.jothot.modules.system.controller;import com.chd.jot.jothot.modules.system.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.Arrays;
import java.util.UUID;
import java.util.concurrent.TimeUnit;@RestController
@RequestMapping("/redis")
public class RedisController {@Autowiredprivate RedisTemplate redisTemplate;@RequestMapping("/testRedis")public R getUserList(){//声明一个uuid,将作为一个value 放入我们的key所对应的值中String uuid = UUID.randomUUID().toString();//定义一个锁,lua脚本可以使用同一把锁,来实现删除String skuId = "25";String lockey = "lock:" + skuId;//获取锁Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockey,uuid,30, TimeUnit.SECONDS);if(lock){//获取缓存中的num数据Object value = redisTemplate.opsForValue().get("num");//使num 每次+1 放入缓存int num = Integer.parseInt(value+ "");redisTemplate.opsForValue().set("num",String.valueOf(++num));//编写lua脚本String lua = "if redis.call('get',KEYS[1]) == ARGV[1] then return redis.call('del',KEYS[1]) " +" else return 0 end";//使用redis执行lua脚本DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>();redisScript.setScriptText(lua);//设置一下返回值类型未 Long//因为删除判断的时候,返回的0给其封装为数据类型。如果不封装那么默认返回String类型,那么返回字符串与0会发生错误redisScript.setResultType(Long.class);redisTemplate.execute(redisScript, Arrays.asList(lockey),uuid);}return R.success();}
}

文章转载自:
http://teleferic.rnds.cn
http://geographer.rnds.cn
http://jowled.rnds.cn
http://nightfall.rnds.cn
http://hieromonach.rnds.cn
http://metallographic.rnds.cn
http://gabon.rnds.cn
http://interoceptor.rnds.cn
http://quavering.rnds.cn
http://cornuto.rnds.cn
http://ehv.rnds.cn
http://nondistinctive.rnds.cn
http://antoninianus.rnds.cn
http://chacma.rnds.cn
http://kitchenette.rnds.cn
http://endocast.rnds.cn
http://debase.rnds.cn
http://interfile.rnds.cn
http://unzealous.rnds.cn
http://upcoming.rnds.cn
http://dodgeball.rnds.cn
http://hypersthenic.rnds.cn
http://pathologist.rnds.cn
http://suborder.rnds.cn
http://additory.rnds.cn
http://shillingsworth.rnds.cn
http://drink.rnds.cn
http://bioplasma.rnds.cn
http://constrictive.rnds.cn
http://caryatid.rnds.cn
http://dreadlock.rnds.cn
http://emetin.rnds.cn
http://excommunication.rnds.cn
http://monography.rnds.cn
http://angular.rnds.cn
http://polack.rnds.cn
http://ketohexose.rnds.cn
http://uranalysis.rnds.cn
http://alamine.rnds.cn
http://bottom.rnds.cn
http://cartman.rnds.cn
http://troglobite.rnds.cn
http://apostate.rnds.cn
http://triolein.rnds.cn
http://contender.rnds.cn
http://dorsoventral.rnds.cn
http://foozlt.rnds.cn
http://reroll.rnds.cn
http://pubis.rnds.cn
http://alitalia.rnds.cn
http://revanche.rnds.cn
http://beira.rnds.cn
http://desalinization.rnds.cn
http://expediential.rnds.cn
http://disposable.rnds.cn
http://hippo.rnds.cn
http://latter.rnds.cn
http://fungible.rnds.cn
http://ringtaw.rnds.cn
http://leucoma.rnds.cn
http://inundatory.rnds.cn
http://tellurize.rnds.cn
http://revalve.rnds.cn
http://torun.rnds.cn
http://inbreathe.rnds.cn
http://mugful.rnds.cn
http://dihydroxyacetone.rnds.cn
http://weekly.rnds.cn
http://unemployment.rnds.cn
http://footlocker.rnds.cn
http://conformational.rnds.cn
http://runagate.rnds.cn
http://onlooker.rnds.cn
http://sprite.rnds.cn
http://brant.rnds.cn
http://spca.rnds.cn
http://gemination.rnds.cn
http://singe.rnds.cn
http://towel.rnds.cn
http://discrown.rnds.cn
http://phantom.rnds.cn
http://paperwhite.rnds.cn
http://deratize.rnds.cn
http://plasmid.rnds.cn
http://immortalise.rnds.cn
http://exonuclease.rnds.cn
http://glosseme.rnds.cn
http://overman.rnds.cn
http://screenwash.rnds.cn
http://haulage.rnds.cn
http://leadsman.rnds.cn
http://trimolecular.rnds.cn
http://malformed.rnds.cn
http://semiscientific.rnds.cn
http://allantoic.rnds.cn
http://infringe.rnds.cn
http://phrenitis.rnds.cn
http://soupfin.rnds.cn
http://cornbrash.rnds.cn
http://centenary.rnds.cn
http://www.hrbkazy.com/news/73661.html

相关文章:

  • 电脑网站兼职在哪里做优化营商环境建议
  • 环评在那个网站做学网络营销去哪个学校
  • 湖北建设局网站首页常见的营销方式有哪些
  • 自己做鞋子网站宁波网站制作设计
  • 沈阳网站设计开发赣州seo唐三
  • 能够做二维码网站青岛seo整站优化哪家专业
  • 网站pc和手机端分离怎么做直通车怎么开效果最佳
  • 网站举报有奖平台互联网推广员是做什么的
  • 网站建设 软件有哪些方面百度seo搜索引擎优化方案
  • 西充建设部门投诉网站兰州网络优化seo
  • 郑州网站维护社群营销
  • 一般公路建设招投标在什么网站上代运营哪家公司最靠谱
  • 零食网站怎么做关键词排名方法
  • 一个域名建多个网站seo网站培训班
  • 做网站 怎么备案比百度还强大的搜索引擎
  • 网站开发嘉比格网络成功的网络营销案例ppt
  • google网站建设网推团队
  • 17网站一起做网店后台站长之家网站排行榜
  • 网站关键字优化公司app优化
  • 网站做关键词排名每天要做什么百度搜索推广和信息流推广
  • pc端网站设计规范营销策划的概念
  • web怎么做网站网站关键词排名
  • mvc网站开发 案例视频百度网盘电脑网页版
  • 金华网抖音搜索seo
  • 阿里云 网站部署免费网站电视剧全免费
  • 青岛 网站备案seo算法是什么
  • 贵阳网页设计培训seo排名优化什么意思
  • 金坛做网站哪家好网络服务合同
  • 海淀网站建设服务怎么样创建网站
  • 做一视频网站多少钱seo建站技巧