Posted 绌嗘枃鏂岀殑鍏紬骞冲彴

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相关的知识,希望对你有一定的参考价值。

鑳屾櫙

鑰侀」鐩敼閫犱腑锛宺edis杩佺Щ锛堣繕鏄€侀」鐩敼閫狆煒濓級銆?/span>

鏃ч泦缇よ繛鎺ヤ笉闇€瑕佸瘑鐮侊紝鑰屾柊闆嗙兢闇€瑕併€傝縼绉绘秹鍙婂埌23涓」鐩€?/span>

鍏朵腑涓€涓」鐩敼閫犱笂绾垮悗鍑虹幇璁よ瘉澶辫触鐨勯棶棰橈紙寮傚父鏃ュ織锛夛細

 [2021-03-30 11:46:29.249 tjtx144-127-214.58os.org happyhours-service] [ERROR] [http-nio-8018-exec-8] (RedisSessionManager:63) [TxId: SpanId:] 鑾峰彇session鏃跺嚭鐜扮紦瀛樺紓甯?寮傚父淇℃伅redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required. at redis.clients.jedis.Protocol.processError(Protocol.java:127) ...

Redis杩炴帴绫讳腑涓昏浠g爜鐗囨锛堜唬鐮佹锛夛細

 public JedisPool func1(JedisPoolConfig jedisPoolConfig) { JedisPool jedisPool = new JedisPool(jedisPoolConfig,host,port); return jedisPool; }  public JedisConnectionFactory func2( JedisPoolConfig jedisPoolConfig) { JedisConnectionFactory factory = new JedisConnectionFactory(); factory.setHostName(host); factory.setPort(port); factory.setPassword(password);//鏀归€犳柊澧?/span> factory.setPoolConfig(jedisPoolConfig); return factory; }

杩佺Щ鏀归€犳椂锛屽彧淇敼浜?code class="mq-12">func2()鍑芥暟锛屽鍔犱簡绗?0琛屻€傝礋璐f敼閫犵殑鍚屽搴旇鏄病鏈夋敞鎰忓埌func1()涓篃鏈夎繛鎺ョ殑鍒濆鍖栬缃€?/span>

涓や釜鍑芥暟瀹炵幇鐨勫姛鑳戒娇鐢ㄤ竴鏍风殑锛屾洿宸х殑鏄敼閫犵殑椤圭洰涓繛鎺edis鎿嶄綔骞舵病鏈変娇鐢?code class="mq-18">func2()...锛屾敼閫犵殑鍚屽娌挎儻鎬ф€濈淮锛堝凡鏀归€犵殑椤圭洰涓兘鐢ㄧ被浼?code class="mq-20">func2()鍑芥暟锛夊彧淇敼浜嗕竴澶勷煒€?/span>

鎵€浠ョ洿鎺ョ殑淇敼鏂瑰紡鏄紝绗?琛屾敼涓猴細

 JedisPool jedisPool =   new JedisPool(jedisPoolConfig,host,port,20000,password);

瀹炵幇瀵规瘮

杩欎釜闂骞朵笉澶嶆潅锛屽€熻繖涓簨鎯冲姣斾竴涓?code class="mq-29">JedisPool鍜?code class="mq-31">JedisConnectionFactory鍔熻兘涓婄殑寮傚悓锛屼互鍙婂湪Pool瀹炵幇涓婃垜瑙夊緱鍊煎緱鍊熼壌鐨勫疄鐜版柟寮忋€?/span>

JedisPool瀹炵幇浜嗕竴涓繛鎺ユ睜Pool銆?/span>

鑰?code class="mq-42">JedisConnectionFactory瀹炵幇浜?em class="mq-44">Cluster銆?em class="mq-47">Sentinel鍜?em class="mq-50">Pool涓夌杩炴帴鏂瑰紡銆?em class="mq-53">Pool鐨勫疄鐜板氨鏄垱寤轰竴涓?code class="mq-56">JedisPool銆?/span>

 //JedisConnectionFactory.java 鍒涘缓Pool鐨勪唬鐮佹 protected Pool<Jedis> createRedisPool() { return new JedisPool(getPoolConfig(), getShardInfo().getHost(),  getShardInfo().getPort(),getTimeoutFrom(getShardInfo()),          getShardInfo().getPassword(),  Protocol.DEFAULT_DATABASE, clientName, useSsl); }

鍙JedisPool鍦ㄥ姛鑳戒笂鍙槸JedisConnectionFactory鐨勪竴涓瓙闆嗐€?/span>

濡傛灉鍙槸鍗曡妭鐐圭殑Redis鍙敤杞婚噺JedisPool鍘诲疄鐜拌繛鎺ョ鐞嗐€傚湪闆嗙兢鍦烘櫙涓嬶紝鏇存帹鑽愪娇鐢?code class="mq-68">JedisConnectionFactory銆?/span>

娣卞叆Pool瀹炵幇

鍐嶆繁鍏ョ湅涓€涓嬭繛鎺ユ睜Pool鐨勫疄鐜般€?/span>

浠庢簮鐮佷笂鐪?code class="mq-79">JedisPool鏀寔浜唖slsocket锛堝畨鍏ㄥ鎺ュ瓧锛夊拰socket锛堟櫘閫氬鎺ュ瓧锛夊崗璁€?/span>

 public JedisPool(final String host) { ...  }  public JedisPool(final String host,         final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,         final HostnameVerifier hostnameVerifier) { ... }

涓€涓湁瓒g殑鍙戠幇鏄?code class="mq-83">JedisPool涓娇鐢?code class="mq-85">GenericObjectPool瀹炰綋锛堝湪鐖剁被Pool.java鐨勫睘鎬т腑瀹氫箟internalPool锛夊畾涔夋睜銆?/span>

椤虹潃杩欐潯绾垮線涓嬬湅锛屽彂鐜?code class="mq-93">GenericObjectPool鏄痑pache瀹炵幇鐨勪竴涓€氱敤鐨勬睜瀵硅薄锛屾敮鎸佹硾鍨嬨€?/span>

杩欓噷浣跨敤LinkedBlockingDeque瀹屾垚鍏蜂綋姹犲璞$殑绠$悊銆?/span>

绫?code class="mq-101">GenericObjectPool.java鐨刄ML鍏崇郴鍥惧涓嬶細

GenericObjectPool.java鎻愪緵鎿嶄綔Pool鐨勫畬鍠勭殑鏂规硶闆?/span>

璁剧疆Pool灞炴€х殑setMaxIdle()銆?code class="mq-121">setMinIdle()浠ュ強鐖剁被BaseGenericObjectPool涓殑灞炴€ц缃嚱鏁般€?code class="mq-125">borrowObject()銆?code class="mq-127">getFactory()绛夊Pool鎿嶄綔鍑芥暟銆?/span>

鎵€鏈夛紝褰撴垜浠渶瑕佽嚜宸卞疄鐜颁竴涓?em class="mq-136">Pool鏃讹紝鍙互鍊熼壌JedisPool鐨勫疄鐜版柟寮忥細闆嗘垚GenericObjectPool绫伙紝鑰屼笉鏄嚜宸卞幓瀹炵幇鏁村Pool鐨勭鐞嗐€?/span>

渚濊禆鐗堟湰

SpringBoot鐨勭増鏈槸锛堟槸鍟婏紝鐗堟湰寰堟棫馃槀锛夛細

 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starters</artifactId> <version>1.5.9.RELEASE</version> </parent>

Jedis渚濊禆锛?/span>

 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency>

以上是关于的主要内容,如果未能解决你的问题,请参考以下文章

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数

VSCode自定义代码片段8——声明函数