Skip to content

Commit

Permalink
Refactor redis plugins
Browse files Browse the repository at this point in the history
Refactor redis plugins
  • Loading branch information
nonacosa committed Apr 22, 2017
1 parent 623088d commit 2506df3
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 25 deletions.
15 changes: 15 additions & 0 deletions webBee-core/src/main/java/org/bee/webBee/DataStoreBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.bee.webBee;

/**
* data 2017-04-22 23:42
* E-mail [email protected]
* @author sis.nonacosa
*/
public interface DataStoreBase<T> {

T insert(T value);

T select();


}
12 changes: 12 additions & 0 deletions webBee-core/src/main/java/org/bee/webBee/DataStoreKV.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.bee.webBee;

/**
* data 2017-04-22 23:42
* E-mail [email protected]
* @author sis.nonacosa
*/
public interface DataStoreKV<T> extends DataStoreBase {

T insert(String key,T value);

}
42 changes: 42 additions & 0 deletions webBee-redis/src/main/java/webbee/redis/RedisHash.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package webbee.redis;

import org.bee.webBee.DataStoreBase;
import org.bee.webBee.DataStoreKV;

import java.util.Map;

/**
* data 2017-04-22 00:19
* E-mail [email protected]
* @author sis.nonacosa
*/
public class RedisHash implements DataStoreBase {

public static String set(String key, Map<String,String> hash){
return Redis.create().hmset(key,hash);

}


public boolean insert(String key, Map<String,String> value) {
return Redis.create().hmset(key, value).equals("OK");
}

@Override
public Object insert(Object value) {
return null;
}

@Override
public Object select() {
return null;
}


public static RedisHash create(){
return new RedisHash();
}



}
16 changes: 0 additions & 16 deletions webBee-redis/src/main/java/webbee/redis/RedisHashUtil.java

This file was deleted.

14 changes: 5 additions & 9 deletions webBee-redis/src/test/java/TestHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import com.alibaba.fastjson.JSON;
import redis.clients.jedis.Jedis;
import webbee.redis.RedisHashUtil;
import webbee.redis.RedisHash;

import java.util.Map;
import java.util.Set;

/**
* data 2017-04-22 00:27
Expand All @@ -25,13 +24,10 @@ public static void main(String[] args) {
"\"avatar_url_template\":\"https://pic4.zhimg.com/eb7442cd6913420418390112f2d1610f_{size}.jpg\"," +
"\"headline\":\"Catch me if you can. 公众号:WeBallsohard \",\"is_following\":\"false\"}");

System.out.println(map.get("name"));
RedisHashUtil.set(map.get("name"),map);

Jedis jedis = new Jedis("127.0.0.1");
System.out.println("asdd"+jedis.sadd("asdd","asddd"));
Set set = jedis.keys("白*");
// jedis.hgetAll("bookname");
System.out.println("set : "+set);
Boolean status = RedisHash.create().insert("name2",map);

System.out.println(status);

}
}

0 comments on commit 2506df3

Please sign in to comment.