Redis High Performance Client-REDISSDK

Source: Internet
Author: User

We first place the redis.properties under our own project, which reads as follows:

#redis地址server =192.168.0.8#redis Port port=6379auth=adminmax_active=600max_idle=300# maximum wait time max_wait=1000# timeout timeout= 3000test_on_borrow=true

Then we write a test class, test the Redis, we want to test the object write, read, then we first write a simple user class.

1  Packagecom.redis.test;2 3 Importjava.io.Serializable;4 5 /**6  * @author[email protected]7  * @version1.08  *9  */Ten  Public classUserImplementsSerializable { One     PrivateString name; A     Private intAge ; -  -      PublicUser (String name,intAge ) { the         Super(); -          This. Name =name; -          This. Age =Age ; -     } +  -      PublicString GetName () { +         returnname; A     } at  -      Public intGetage () { -         returnAge ; -     } -  -      Public voidsetName (String name) { in          This. Name =name; -     } to  +      Public voidSetage (intAge ) { -          This. Age =Age ; the     } *  $}

We write our Redis test class, and I've already written the SDK, which contains code that serializes the deserialized object.

1  Packagecom.redis.test;2 3 ImportCom.redissdk.redis.RedisUtil;4 5 /**6  * @author[email protected]7  * @version1.08  *9  */Ten  Public classTestredis { One      Public Static voidMain (string[] args) { A  -Redisutil.setstring ("Redis key", "Redis HelloWorld", redisutil.exrp_day); -System.out.println (redisutil.getstring ("Redis key")); the  -User User =NewUser ("Zhang San", 23); - System.out.println (Redisutil -. SetObject ("User", user, redisutil.exrp_day)); + System.out.println (Redisutil -. SetObject ("User2", user, redisutil.exrp_day)); +User User1 = Redisutil.getobject ("User", user.class); ASystem.out.println ("Name:" + user1.getname () + "Age:" +user1.getage ()); at  -System.out.println (Redisutil.getkeys ("*")); -         //Redisutil.getjedis () Other unpackaged methods need to invoke the original object method Operation -     } -}

We run to see the results:

Ok,redis Java environment In this configuration is complete, the SDK only implemented string and object of the increase, delete, check. Set map and so on also need to call [Redisutil.getjedis ()], get Jedis object method directly access.

SOURCE download

Redis High Performance Client-REDISSDK

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.