Redis provides a flexible way of querying data, and the most bull is the search for key to support regular expressions.
Jedis.keys ("*") means search for all key
Jedis.keys ("abc*") indicates the search for key data beginning with ABC
The key is traversed to the value.
is actually a set
Copy Code code as follows:
Redisdo rd = new redisdo ();
Rd.open ();
Set s = Rd.jedis.keys ("*");
Iterator it = S.iterator ();
while (It.hasnext ()) {
String key = (string) it.next ();
String value = Rd.jedis.get (key);
SYSTEM.OUT.PRINTLN (key + value);
}
Rd.close ();
RD's algorithm for integrated Redis operations
Copy Code code as follows:
Package Com.javaer.click.way;
Import Redis.clients.jedis.Jedis;
Import Redis.clients.jedis.JedisPool;
Import Redis.clients.jedis.JedisPoolConfig;
Import redis.clients.jedis.exceptions.JedisConnectionException;
public class Redisdo {
Public Jedis Jedis;
public void Close () {
Jedis.disconnect ();
Jedis = null;
}
Public Jedis open () {
Jedispoolconfig config = new Jedispoolconfig ();
Config.setmaxactive (100);
Config.setmaxidle (20);
Config.setmaxwait (1000l);
Jedispool Pool;
Pool = new Jedispool (config, "xxxxxxxx.xx.xx.xx", 6379);
Boolean borroworoprsuccess = true;
try {
Jedis = Pool.getresource ();
Do Redis opt by instance
catch (Jedisconnectionexception e) {
Borroworoprsuccess = false;
if (Jedis!= null)
Pool.returnbrokenresource (Jedis);
finally {
if (borroworoprsuccess)
Pool.returnresource (Jedis);
}
Jedis = Pool.getresource ();
return Jedis;
}
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
}
}