Package com.juanpi.plugins;
Import Com.juanpi.common.CalendarUtil;
Import Com.juanpi.common.RedisUtil;
Import Java.util.Calendar;
Import Java.util.Iterator;
Import Java.util.Map;
Import Java.util.Set;
Import Net.minidev.json.JSONArray;
Import Net.minidev.json.JSONObject;
Import Net.minidev.json.JSONValue;
Import Org.apache.commons.logging.Log;
Import Redis.clients.jedis.Jedis; public class Testset {public static void main (string[] args) throws Exception {Redisutil Redisutil = REDISUTIL.G
Etinstance ();
Jedis Redis = Redisutil.getjedis ();
try {redis.clientsetname ("Test_redis");
Jsonobject USER_KQ = new Jsonobject ();
String _key= "20140423";
for (int i=1;i<3;i++) {user_kq.clear ();
User_kq.put ("UID", i+ "1");
User_kq.put ("App", "1");
User_kq.put ("from", "2");
User_kq.put ("ClientID", "123"); Redis.sadd (_key, User_kq.tojsOnstring ()); } System.out.println (Redis.smembers (_key));/return all data in a collection System.out.println (Redis.scard (_key));
Returns the quantity in the collection System.out.println (Redis.sismember (_key, user_kq.tojsonstring ()));//Determine whether a member is in the collection//Traversal collection
Set<string> smember=redis.smembers (_key);
Iterator<string> it = Smember.iterator ();
while (It.hasnext ()) {String j=it.next ();
Jsonobject json = (jsonobject) jsonvalue.parse (j);
System.out.println (Json.get ("UID"));
The catch (Exception e) {Redisutil.releasejedis (Redis);
E.printstacktrace ();
}
}
}