- public static RedisDao jedis;
-
- public static void main(String[] args) {
-
-
- jedis=(RedisDao) context.getBean("redisDao");
-
- jedis.set("testKey","testValue");
-
- jedis.set("testValid",new Date().toString(), 30);
- jedis.rpush("11", "22", "33", "44", "55");
-
-
- int count=jedis.getKeyCount("");
- String testkey=jedis.get("bb");
- List <String> students = jedis.lrange("11", 0, -1) ;
-
- System.out.println("testkey========="+testkey);
- System.out.println("testlist========="+students.toString());
- System.out.println("test=========count="+count);
- }
-
-
- @Test
- public void test01(){
-
- jedis.set("name", "hello");
- String value = jedis.get("name");
- System.out.println(value);
-
- jedis.del("name");
- value = jedis.get("name");
- System.out.println(value);
- }
-
-
- @Test
- public void test02(){
-
-
- jedis.rpush("students", "first");
-
-
- jedis.lpush("students", "end");
-
-
- jedis.lpop("students");
-
-
- jedis.rpop("students");
-
-
- jedis.lrem("student", 1, "first") ;
-
- List <String> students = jedis.lrange("students", 0, -1) ;
-
- System.out.println(students);
- }
-
-
- @Test
- public void test03(){
-
- jedis.sadd("teachers", "zhangsan");
- jedis.sadd("teachers", "lisi","hello");
- jedis.sadd("teachers", "wangwu");
-
-
- Boolean b1 = jedis.sismember("teachers", "wangwu");
- Boolean b2 = jedis.sismember("teachers", "xxxxx");
- System.out.println(b1 + " " + b2);
-
-
- Set<String> members = jedis.smembers("teachers");
- Iterator<String> it = members.iterator() ;
- while(it.hasNext()){
- System.out.println(it.next());
- }
-
-
-
- }
-
-
- @Test
- public void test04(){
-
- jedis.zadd("emps", 5 , "aaa") ;
- jedis.zadd("emps", 1 , "bbbb") ;
- jedis.zadd("emps", 3 , "ccc") ;
- jedis.zadd("emps", 2 , "ddd") ;
-
-
- Set<String> emps = jedis.zrange("emps", 0, -1) ;
- Iterator<String> it = emps.iterator() ;
- while(it.hasNext()){
- System.out.println(it.next());
- }
- }
-
-
- @Test
- public void test05(){
- Map<String , String > car = new HashMap<String , String >() ;
- car.put("COLOR", "red") ;
- car.put("SIZE", "2T");
- car.put("NO", "8888");
-
- jedis.hmset("car", car);
-
-
- Map<String, String> result = jedis.hgetAll("car");
- Iterator<Entry<String, String>> it = result.entrySet().iterator();
- while(it.hasNext()){
- Entry<String, String> entry = it.next() ;
- System.out.println("key:" + entry.getKey() + " value:" + entry.getValue());
- }
-
-
- String no = jedis.hget("car", "NO") ;
- System.out.println("NO:" + no);
- }