Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of Redis

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Redis installation

Redis official website: https://redis.io/download

I installed Redis on Centos7, and you can see the installation method on the official website. Step: download-decompress-compile-install.

$wget http://download.redis.io/releases/redis-4.0.2.tar.gz

$tar xzf redis-4.0.2.tar.gz

$cd redis-4.0.2

$make

$cd src

$make install

Installation of Redis requires the support of tcl. Execute the following command to install it:

$yum install tcl

After the Redis installation is completed, in order to facilitate management in the future, I moved the configuration and commands of Redis to a unified file (or not, depending on my preferences), and I moved the configuration and commands to / usr/local/redis/etc and / usr/local/redis/bin, respectively.

The common commands for viewing are as follows, where redis-server is used to start the Redis server and redis-cli is used to start the Redis client.

Start the Redis service

The startup mode of the Redis server is the redis-server command with the configuration file path, and without the configuration file path, the default configuration is used. By default, the Redis service starts directly in the foreground, and you can make the Redis service run in the background by changing the property value of daemonize in the configuration file to yes.

Change the Redis service to run in the background, and start the Redis service again. You can see that the Redis service is already running in the background and uses the default port number 6379 in the configuration file.

Connect to the service using the Redis client

Redis-cli can start a redis client, with-p specifying the port number, or using the default port number if not specified. Once connected, we can do some operations. Here, I use the local redis client to connect, or I can use the remote method. The default Redis client does not need a password to connect to the Redis server. You can change the value of requirepass in the configuration file to make the Redis client connection require a password, which can also make the Redis service more secure.

Test the performance of the Redis service

Redis-benchmark can be used to test the performance of Redis services.

. / redis-benchmark-h 127.0.0.1-p 6379-c 1000-n 50000-Q # 1000 concurrent connections, 50000 requests, host 127.0.0.1 port 6379 performance of the Redis service.

Using Redis in Java

1. Download driver: https://mvnrepository.com/artifact/redis.clients/jedis

two。 Include in classpath

Jedis 2.8.0 API: http://javadox.com/redis.clients/jedis/2.8.0/overview-summary.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report