Installation and operational implementation of the Jedis database (Windows maven project)

Source: Internet
Author: User

Redis is an in-memory database that caches the data you write into memory and then periodically writes to disk, and this article describes the operation of using MAVEN tools to compile and run Java files in a Windows environment to implement a Redis database.
First, we need to download the Redis tool: Http://redis.io/download, then unzip it, and we'll see that there are files in the extracted directory:
Of these, two executables need to be considered, Redis-server.exe/redis-cli.exe, which are Redis services and Redis clients, to run Redis, we need to execute the server file as shown in:
Next, we open the Redis-cli file and we can interact with Redis-server:

In, you can see that I executed on the client: Keys * (list key in database), get ZHANGHU1 (get key corresponding value), other shell commands can be Google or Baidu.

MAVEN is an effective tool for project management, it can download the program's dependency package according to the user's definition, and so on, this is Maven's: https://maven.apache.org/download.cgi. After the download is done, the bin directory is loaded into the environment variable, which is verified by typing it at the command line: mvn-version, if an interface similar to the one shown is displayed, the installation is complete.
The MAVEN project has its own directory building rules (Maven provides an automated build tool: MVN archetype), Its configuration file is Pom.xml, it is located under the root of the project, we need to use Java to operate Redis, we need to use the Jedis class, we need to add dependencies under the Pom, then pom.xml becomes this:
<project xmlns= "http://maven.apache.org/POM/4.0.0"         xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"         xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >    <modelVersion>4.0.0</modelVersion>    <groupid>com.xiaomi.first.storedatatoredis</ groupid>    <artifactId>StoreDataToRedis</artifactId>    <version>1.0-snapshot</ version>    <dependencies>        <dependency>            <groupId>redis.clients</groupId>            <artifactId>jedis</artifactId>            <version>2.7.2</version>        </dependency >    </dependencies></project>

After that, we use the interface provided by Jedis to write to the database, read, and so on. Redis itself provides a rich set of data types, such as strings, collections, linked lists, and so on, where you can query the build rules of MAVEN projects and the interfaces provided by Jedis.
Below, I'll show you how to compile and execute code to implement the database operations:
1. We need to go to the root of the project, execute MVN compile, and if it is first executed, MAVEN will download the appropriate compilation tool
2. Execution: mvn exec:java-dexec.mainclass= "package name. Class Name" (with input parameters: MVN exec:java-dexec.mainclass= "Package name". Class name "-dexec.args=" arg0 arg1 Arg2 ")
The process of compiling and executing is shown:
1. Compile the process:

2. Execution process:

When we see the build success that represents the success of the project, let's verify that the data is available in Redis:


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Installation and operational implementation of the Jedis database (Windows maven project)

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.