يتبنى العميل أحدث Jedis 2.7
1. التبعيات:
<Rependency> <roupiD> redis.clients </groupId> <StifactId> jedis </stifactId> <soph> 2.7.3 </version> </reperence>
2. أضف تكوين الربيع
<bean name = "genericObjectPoolConfig"> <property name = "maxwaitmillis" value = "-1" /> <property name = "maxtotal" value = "1000" /> <property name = "minidle" value = "8" /> <property name = "maxidle" name = "addressConfig"> <value> classpath: connect-redis.properties </value> </sopporment> <property name = "addractKeyPrefix" value = "address" /> <!-prefix of key in the property file-> <property name = "timeout" value = "300000" /> <property name = maxRediStions Ref = "GenericObjectPoolConfig" /> </ban>
3. أضف ملف تكوين Connect-Redis.Properties
تم تكوين 6 عقد هنا
address1 =*:*address2 =*:*address3 =*:*address4 =*:*address5 =*:*address6 =*:*address6 =*:*
4. إضافة فئة جافا:
استيراد java.util.hashset ؛ استيراد java.util.properties ؛ استيراد java.util.set ؛ استيراد java.util.regex.pattern ؛ import org.apache.commons.pool2.impl.impl.impl.ImnericObjectPoolConfig ؛ org.springframework.beans.factory.initializingbean ؛ استيراد org.springframework.core.io.resource ؛ redis.clients.jedis.hostandpor addresseKypRefix ؛ jediscluster jediscluster ؛ مهلة عدد صحيح خاص ؛ عدد صحيح خاص maxredirection jediscluster ؛}@outridepublic class <؟ يمتد jediscluster> getObjectType () {return (this.jediscluster! = null؟ this.jediscluster.getClass (): jediscluster.class) ؛}@Outderidepublic Boolean issingleton () {return true ؛ Properties () ؛ prop.load (this.addressConfig.getInputStream ()) ؛ set <SextAndPort> hasps = new hashset <SoxtAndPort> () ؛ for (مفتاح الكائن: prop.keyset ()) {if (! p.matcher (val) .matches () ؛ if (! isiPport) {رمي جديد alficalArgumentException ("IP أو المنفذ غير قانوني") ؛} String [] ipandport = val.split (":": ") (alfulalArgumentException ex) {throw ex ؛} catch (استثناء ex) {رمي استثناء جديد ("فشل ملف تكوين parse jedis" ، ex) ؛}}@overridepublic void بعد propertiesset () يلقي الاستثناء MaxRedIrections ، genericObjectPoolConfig) ؛} public void setAddressConfig (Resource addressConfig) {this.addressConfig = addressConfig ؛} public void setTimeOut (int this.maxedrices ؛ setAddressKeypRefix (string addressKeypRefix) {this.addressKeypRefix = addractKeypRefix ؛} public void setGenericObjectPoolConfig (genericObjectPoolConfig genericObjectPoolConfig) {this.genericobjectpoolconfig = genericobjectpoulconfig ؛}}} 5. تم الانتهاء من التكوين في هذه المرحلة
عندما تكون قيد الاستخدام ، فقط حقنها مباشرة ، كما هو موضح أدناه:
@autowiredjediscluster jediscluster ؛
لخص
ما سبق هو كل التفسير المفصل لمجموعة Redis Integration Redis ، آمل أن يكون مفيدًا للجميع. إذا كانت هناك أي أوجه قصور ، فيرجى ترك رسالة لإشارةها. شكرا لك يا أصدقائك لدعمكم لهذا الموقع!