Single Service cache Redis tool class

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.