Package Redistest;import Redis.clients.jedis.jedis;public class Redistest {private static String HOST = "192.168.43.22"; private static int PORT = 6379;public static void Main (string[] args) {//Connect Redis database Jedis Jedis = new Jedis (host,port);/** * String Operation *//*jedis.set ("name", "GWB"), Jedis.append ("name", " Hello"), *//** * Redis's own operating industry *//*// Delete all Keyjedis.flushall () from all databases,//delete all KEYJEDIS.FLUSHDB () from the current database, Jedis.select (1); *//** * Set Operation **//*jedis.flushdb (); System.out.println (Jedis.dbsize ()); *///jedis.sadd ("Set1", "Lisi", "Wangwu");//system.out.println (Jedis.keys ("*") ); Jedis.sadd ("Set1", "Lisi", "Wangwu", "Gouliu"), Jedis.lpush ("name1", "name2"); System.out.println (Jedis.lrange ("Name1", 0,-1)); System.out.println (Jedis.smembers ("Set1"));/** * Hash Operation *//*jedis.hset ("info", "name", "GWB"), Jedis.hset ("info", " Age "," 20 "); System.out.println (Jedis.hget ("info", "name") + "" +jedis.dbsize ()); */}}
Java Simple Operation Redis Database