本文整理汇总了Java中redis.clients.jedis.Protocol.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于redis.clients.jedis.Protocol包,在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getErrorAfterConnectionReset
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
@Test
public void getErrorAfterConnectionReset() throws Exception {
class TestConnection extends Connection {
public TestConnection() {
super("localhost", 6379);
}
@Override
protected Connection sendCommand(ProtocolCommand cmd, byte[]... args) {
return super.sendCommand(cmd, args);
}
}
TestConnection conn = new TestConnection();
try {
conn.sendCommand(Command.HMSET, new byte[1024 * 1024 + 1][0]);
fail("Should throw exception");
} catch (JedisConnectionException jce) {
assertEquals("ERR Protocol error: invalid multibulk length", jce.getMessage());
}
}
示例2: getErrorAfterConnectionReset
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
@Test
public void getErrorAfterConnectionReset() throws Exception {
class TestConnection extends Connection {
public TestConnection() {
super("localhost", 6379);
}
protected boolean sendCommand(Command cmd, byte[]... args) {
return super.sendCommand(cmd, args);
}
}
TestConnection conn = new TestConnection();
try {
conn.sendCommand(Command.HMSET, new byte[1024 * 1024 + 1][0]);
fail("Should throw exception");
} catch (JedisConnectionException jce) {
assertEquals("ERR Protocol error: invalid multibulk length", jce.getMessage());
}
}
示例3: process
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
@Around("execution(* redis.clients.jedis.Protocol.*sendCommand(..))")
public Object process(ProceedingJoinPoint point) throws Throwable {
System.out.println("@Around:执行目标方法之前...");
//访问目标方法的参数:
Object[] args = point.getArgs();
//进行业务验证
long begin = System.nanoTime();
if(null!=args && null!=args[1] && args[1] instanceof Command){
logger.info("command:"+((Command)args[1]).name()+","+CacheUtils.getSendCommondSizeType(args));
}else if (null!=args && null!=args[1] && args[1] instanceof byte[]){
logger.info("command:"+new String((byte[])args[1])+","+CacheUtils.getSendCommondSizeType(args));
}else{
logger.info(CacheUtils.getSendCommondSizeType(args));
}
Object returnValue = point.proceed(args);
long time = System.nanoTime() - begin;
logger.info(point.getSignature()+",last "+time/1000000+"ms");
System.out.println("@Around:执行目标方法之后...");
return returnValue;
}
示例4: sendCommand
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
protected Connection sendCommand(final Command cmd, final String... args) {
final byte[][] bargs = new byte[args.length][];
for (int i = 0; i < args.length; i++) {
bargs[i] = SafeEncoder.encode(args[i]);
}
return sendCommand(cmd, bargs);
}
示例5: doSendCommandStart
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
public Object doSendCommandStart(Object[] args) {
Command cmd = (Command) args[0];
String host = (String) args[2];
Integer port = (Integer) args[3];
String targetURL = "redis://" + host + ":" + port;
String redisAction = cmd.name();
if (logger.isDebugable()) {
logger.debug("REDIS INVOKE START: " + targetURL + " action: " + redisAction, null);
}
Map<String, Object> params = new HashMap<String, Object>();
params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, targetURL);
params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, redisAction);
params.put(CaptureConstants.INFO_CLIENT_APPID, appid);
params.put(CaptureConstants.INFO_CLIENT_TYPE, "redis.client.Jedis");
UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT,
Monitor.CapturePhase.PRECAP, params);
// register adapter
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "registerAdapter",
JedisClientAdapter.class);
ivcContextParams = (Map<String, Object>) UAVServer.instance().runSupporter(
"com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap",
InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params,
JedisClientAdapter.class, args);
return null;
}
示例6: eval
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
@Override
public Object eval(String script, String key) {
Span span = helper.buildSpan(Command.EVAL.name(), key);
span.setTag("script", script);
try {
return super.eval(script, key);
} catch (Exception e) {
onError(e, span);
throw e;
} finally {
span.finish();
}
}
示例7: evalsha
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
@Override
public Object evalsha(String script, String key) {
Span span = helper.buildSpan(Command.EVALSHA.name(), key);
span.setTag("script", script);
try {
return super.evalsha(script, key);
} catch (Exception e) {
onError(e, span);
throw e;
} finally {
span.finish();
}
}
示例8: sendCommand
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
protected Connection sendCommand(final Command cmd, final String... args) {
final byte[][] bargs = new byte[args.length][];
for (int i = 0; i < args.length; i++) {
bargs[i] = SafeEncoder.encode(args[i]);
}
return sendCommand(cmd, bargs);
}
示例9: infoAll
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
/**
* Sends the "INFO all" command.
*/
public Properties infoAll() {
sendCommand(Command.INFO, "all");
String reply = getBulkReply();
Properties p = new Properties();
try {
p.load(new StringReader(reply));
} catch (IOException e) {
throw new JedisDataException(e);
}
return p;
}
示例10: ping
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
public void ping() {
sendCommand(Command.PING);
}
示例11: set
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
public void set(final byte[] key, final byte[] value) {
sendCommand(Command.SET, key, value);
}
示例12: get
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
public void get(final byte[] key) {
sendCommand(Command.GET, key);
}
示例13: asking
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
public void asking() {
sendCommand(Command.ASKING);
}
示例14: set
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
public void set(final byte[] key, final byte[] value) {
sendCommand(Command.SET, key, value);
}
示例15: get
import redis.clients.jedis.Protocol.Command; //导入依赖的package包/类
public void get(final byte[] key) {
sendCommand(Command.GET, key);
}