Package Com.alex.xiyoubang;
Import java.util.List;
Import Redis.clients.jedis.BinaryClient.LIST_POSITION;
Import Redis.clients.jedis.Jedis;
public class Jedislist {static Jedis Jedis = new Jedis ("192.168.1.171", 6379);
public static void Main (string[] args) {System.out.println ("==list==");
Emptying Data System.out.println (JEDIS.FLUSHDB ());
Add Data Jedis.rpush ("names", "Tang Priest");
Jedis.rpush ("Names", "Goku");
Jedis.rpush ("Names", "eight Commandments");
Jedis.rpush ("Names", "Wu Jing"); Then take out all the data jedis.lrange is out by range,//The first is key, the second is the starting position, the third is the end position, Jedis.llen gets the length-1 means get all list<string> Valu
ES = Jedis.lrange ("Names", 0,-1);
System.out.println (values);
Emptying Data System.out.println (JEDIS.FLUSHDB ());
Add Data Jedis.lpush ("scores", "100");
Jedis.lpush ("Scores", "99");
Jedis.lpush ("scores", "55");
Array length System.out.println (Jedis.llen ("scores")); //Sort System.out.println (Jedis.sort ("scores"));
String System.out.println (Jedis.lrange ("scores", 0, 3));
Modifies a single value in the list Jedis.lset ("scores", 0, "66");
Gets a list that specifies the value of the System.out.println (Jedis.lindex ("scores", 1));
The Delete list specifies the underlying value System.out.println (Jedis.lrem ("scores", 1, "99"));
Delete data outside the interval System.out.println (Jedis.ltrim ("scores", 0, 1));
List out Stack System.out.println (Jedis.lpop ("scores"));
The entire list value System.out.println (Jedis.lrange ("scores", 0,-1)); Before 100, add the data data Jedis.linsert ("scores", list_position.
Before, "100", "22"); After 100, add the data data Jedis.linsert ("scores", list_position.
After, "100", "77");
The entire list value System.out.println (Jedis.lrange ("scores", 0,-1));
Change the second data of key scores in list to Jedis.lset ("scores", 1, "88");
The entire list value System.out.println (Jedis.lrange ("scores", 0,-1));
Intercept elements within a list interval Jedis.ltrim ("Scores", 1, 2);
The entire list value System.out.println (Jedis.lrange ("scores", 0,-1)); Inserts the value values into the footer of the list key when and only if key exists and is a list.
When key does not exist, the RPUSHX command does nothing.
Jedis.rpushx ("name", "Alex");
System.out.println (Jedis.lrange ("name", 0,-1)); }
}
List command detailed description see: http://blog.csdn.net/qq_32347977/article/details/50510231