diff --git a/webBee-core/src/main/java/org/bee/webBee/DataStoreBase.java b/webBee-core/src/main/java/org/bee/webBee/DataStoreBase.java new file mode 100644 index 0000000..9db819d --- /dev/null +++ b/webBee-core/src/main/java/org/bee/webBee/DataStoreBase.java @@ -0,0 +1,15 @@ +package org.bee.webBee; + +/** + * data 2017-04-22 23:42 + * E-mail sis.nonacosa@gmail.com + * @author sis.nonacosa + */ +public interface DataStoreBase { + + T insert(T value); + + T select(); + + +} diff --git a/webBee-core/src/main/java/org/bee/webBee/DataStoreKV.java b/webBee-core/src/main/java/org/bee/webBee/DataStoreKV.java new file mode 100644 index 0000000..a53cced --- /dev/null +++ b/webBee-core/src/main/java/org/bee/webBee/DataStoreKV.java @@ -0,0 +1,12 @@ +package org.bee.webBee; + +/** + * data 2017-04-22 23:42 + * E-mail sis.nonacosa@gmail.com + * @author sis.nonacosa + */ +public interface DataStoreKV extends DataStoreBase { + + T insert(String key,T value); + +} diff --git a/webBee-redis/src/main/java/webbee/redis/RedisHash.java b/webBee-redis/src/main/java/webbee/redis/RedisHash.java new file mode 100644 index 0000000..2612bc4 --- /dev/null +++ b/webBee-redis/src/main/java/webbee/redis/RedisHash.java @@ -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 sis.nonacosa@gmail.com + * @author sis.nonacosa + */ +public class RedisHash implements DataStoreBase { + + public static String set(String key, Map hash){ + return Redis.create().hmset(key,hash); + + } + + + public boolean insert(String key, Map 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(); + } + + + +} diff --git a/webBee-redis/src/main/java/webbee/redis/RedisHashUtil.java b/webBee-redis/src/main/java/webbee/redis/RedisHashUtil.java deleted file mode 100644 index fe482f2..0000000 --- a/webBee-redis/src/main/java/webbee/redis/RedisHashUtil.java +++ /dev/null @@ -1,16 +0,0 @@ -package webbee.redis; - -import java.util.Map; - -/** - * data 2017-04-22 00:19 - * E-mail sis.nonacosa@gmail.com - * @author sis.nonacosa - */ -public class RedisHashUtil { - - public static void set(String key, Map hash){ - Redis.create().hmset(key,hash); - - } -} diff --git a/webBee-redis/src/test/java/TestHash.java b/webBee-redis/src/test/java/TestHash.java index c01e270..9b18bd3 100644 --- a/webBee-redis/src/test/java/TestHash.java +++ b/webBee-redis/src/test/java/TestHash.java @@ -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 @@ -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); + } }