In view of redis list, hash, set, string and other types of operations, many people are familiar with the use of, a brief introduction to dynamic parameter modification, master-slave switchover, persistent settings, system information monitoring.
Redis Chinese document, there is a detailed description of the console operation, http://redis.readthedocs.org/en/latest/index.html
The following content is the java api application.
- PackageRedis;
- ImportJava. util. List;
- ImportJava. util. UUID;
- ImportRedis. clients. jedis. Jedis;
- ImportRedis. clients. jedis. ShardedJedis;
- ImportRedis. clients. util. ShardInfo;
- /**
- * @ Author Andy
- */
- Public ClassRedisMasterSlaveTest {
- Private Static FinalString HOST ="";
- Private Static Final IntPORT =0;
- /**
- * Add Test Data
- */
- Private Static VoidSetData (Jedis jedis ){
- For(IntI =0; I <100; I ++ ){
- FinalString a = UUID. randomUUID (). toString ();
- Jedis. set (a, );
- }
- }
- /**
- * Dbsize total number of database keys
- */
- Private Static LongGetDBSize (Jedis jedis ){
- ReturnJedis. dbSize ();
- }
- /**
- * Query persistence policies
- */
- Private StaticList <String> getSaveConfig (Jedis jedis ){
- ReturnJedis. configGet ("Save");
- }
- /**
- * Set persistence policies
- */
- Private StaticString setSaveConfig (Jedis jedis ){
- String celue_1 =800 1";
- String celue_2 =400 2";
- ReturnJedis. configSet ("Save", Celue_1 +""+ Celue_2 );
- }
- /**
- * Persistence of data after IO blocking and shutdown redis)
- */
- Private StaticString shutdown (Jedis jedis ){
- ReturnJedis. shutdown ();
- }
- /**
- * Set redis as the master database
- */
- Private StaticString slaveofNoOne (Jedis jedis ){
- ReturnJedis. slaveofNoOne ();
- }
- /**
- * Set this redis instance to slaveof slave Database Based on host/port.
- */
- Private StaticString slaveof (Jedis jedis ){
- ReturnJedis. slaveof (HOST, PORT );
- }
- /**
- * Query the info information of redis.
- */
- Private StaticString info (Jedis jedis ){
- ReturnJedis.info ();
- }
- /**
- * Select?
- */
- Private StaticString select (Jedis jedis ){
- ReturnJedis. 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 ~