ImportRedis.clients.jedis.Jedis;ImportRedis.clients.jedis.JedisPool;ImportRedis.clients.jedis.JedisPoolConfig;/** * Single Service cache Redis Tool Class (requires additional jar package Jedis) */ Public class redissingletonpool { Private StaticString IP = configutil.readconfigforobject ("Singletonip", String.class);Private Static intPort = Configutil.readconfigforobject ("Singletonport", Integer.class);Private StaticJedispool Jedispool =NULL;/** * Get redis Connection Pool * * @return * * Public StaticJedispoolGet_jedispool() {if(Jedispool = =NULL) {Jedispoolconfig Jedispool_config =NewJedispoolconfig ();//Maximum number of active objectsJedispool_config.setmaxactive ( -);//Object Max idle timeJedispool_config.setmaxidle (Ten);//Maximum wait time for object acquisitionJedispool_config.setmaxwait ( theL); Jedispool_config.settestonborrow (true); Jedispool =NewJedispool (Jedispool_config, IP, port); }returnJedispool; } Public Static void Main(string[] args) {Jedis Redis = (Jedis) get_jedispool (). GetResource (); System.out.println (Redis.get ("123")); }}
Single Service cache Redis tool class