Calling Redis using a Java client

Source: Internet
Author: User

Redis supports many programming language clients, C, C #, C + +, Clojure, Common Lisp, Erlang, Go, Lua, Objective-c, PHP, Ruby, Scala, Even the more fashionable node. js, of course, is more than Java's client support. Redis's official list of Java clients is also small, with Jedis, Jredis, Jdbc-redis, RJC, and, of course, Jedis is the official Redis preferred Java Client Development package.

Below we simply introduce the introduction of Jedis.
I use the tool is idea, the first step to create a MAVEN project is as follows:

1. Before creating the project, turn on the Redis boot to open your CMD interface, navigate to the Redis installation directory input command Redis-server redis.conf Enter the boot, start the result is this proves successful

2. Create your MAVEN project, which explains why you can create a MAVEN project because it is convenient and does not need to download the Redis dependency package, just add dependencies directly to the Pom.xml file.

The steps to create are as follows:

Next after:

Enter GroupID and Artifactid I won't explain, then next a maven project is done!

The Pom.xml dependency code is as follows:

Red circle of the dependency package can not be added, the landlord is connected in another way so added, you do not need.

2. Then, using the JUnit test, store a string with the key hw,value as Hello Word, and then get the key value, which is the following code:

Here the Main method please note that the red circle marks the place where eclipse may need to be written, Jedis Jedis =new Jedis ("127.1.0.1", 6379); Add a port number, which is not required here, Adding a port number throws an exception. It's OK. Use your JUnit test to run and see the console output of Hello Word

Big God do not spray, share to the introduction of the small white, in fact, I am, haha! Seung-so

Calling Redis using a Java client

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.