Dynamic configuration of redis Parameters Based on Java

Source: Internet
Author: User

Many users are familiar with redis list, hash, set, string, and other operations,

This section briefly introduces the dynamic parameter modification, master-slave switchover, persistent settings, and system information monitoring.

The redis Chinese document provides detailed instructions on console operations,

Http://redis.readthedocs.org/en/latest/index.html

The following content is the Java API application.

Package redis; import Java. util. list; import Java. util. UUID; import redis. clients. jedis. jedis; import redis. clients. jedis. shardedjedis; import redis. clients. util. shardinfo;/*** @ author Andy */public class redismasterslavetest {Private Static final string host = ""; Private Static final int Port = 0; /*** add Test Data */Private Static void setdata (Jedis) {for (INT I = 0; I <100; I ++) {final string a = u UID. randomuuid (). tostring (); Jedis. set (A, A) ;}}/*** dbsize Total Database keys */Private Static long getdbsize (Jedis) {return Jedis. dbsize ();}/*** query persistence policy */Private Static list <string> getsaveconfig (Jedis) {return Jedis. configget ("save");}/*** set persistence policy */Private Static string setsaveconfig (Jedis) {string celue_1 = "800 1 "; string celue_2 = "400 2"; return Jedis. configset ("save", celue_1 +" "+ Celue_2);}/*** persistent data after Io blocking and then shutdown redis */Private Static string Shutdown (Jedis) {return Jedis. shutdown ();}/*** set this redis master database */Private Static string slaveofnoone (Jedis) {return Jedis. slaveofnoone ();}/*** set this redis instance to slaveof slave Database Based on host/port */Private Static string slaveof (Jedis) {return Jedis. slaveof (host, Port);}/*** query the info information of redis */Private Static string Info (Jedis Jedis) {return jedis.info ();}/*** select? */Private Static string select (Jedis) {return Jedis. Select (1 );}}

There is a way to reset the system parameters. After testing, it is useless, so it is not written.

The select method has not been used. If you have used it, you can follow the instructions to introduce it ~

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.