io.lettuce.core.KeyValue Java Examples

The following examples show how to use io.lettuce.core.KeyValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisBackedSessionMap.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Override
public URI getUri(SessionId id) throws NoSuchSessionException {
  Require.nonNull("Session ID", id);

  RedisCommands<String, String> commands = connection.sync();

  List<KeyValue<String, String>> rawValues = commands.mget(uriKey(id), capabilitiesKey(id));

  String rawUri = rawValues.get(0).getValueOrElse(null);
  if (rawUri == null) {
    throw new NoSuchSessionException("Unable to find URI for session " + id);
  }

  try {
    return new URI(rawUri);
  } catch (URISyntaxException e) {
    throw new NoSuchSessionException(String.format("Unable to convert session id (%s) to uri: %s", id, rawUri), e);
  }
}
 
Example #2
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> brpop(long timeout, K... keys) {
  Span span = helper.buildSpan("brpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.brpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #3
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> brpop(long timeout, K... keys) {
  Span span = helper.buildSpan("brpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.brpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #4
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> hmget(K key, K... fields) {
  Span span = helper.buildSpan("hmget", key);
  try {
    return commands.hmget(key, fields);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #5
Source File: RedisSinkTask.java    From kafka-connect-redis with Apache License 2.0 5 votes vote down vote up
static SinkOffsetState state(KeyValue<byte[], byte[]> input) {
  if (!input.hasValue()) {
    return null;
  }
  try {
    return ObjectMapperFactory.INSTANCE.readValue(input.getValue(), SinkOffsetState.class);
  } catch (IOException e) {
    throw new DataException(e);
  }
}
 
Example #6
Source File: LettuceAsyncService.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@Override
public Object send(String[] params) {
    // 同步与异步均需要返回结果

    LettuceCommandResult lcr = new LettuceCommandResult();
    RedisAdvancedClusterAsyncCommands<String, String> commandAsync = connect.async();
    RedisFuture<List<KeyValue<String, String>>> result = commandAsync.hmget(params[0],
            Arrays.copyOfRange(params, 1, params.length));
    Map<String, String> results = new HashMap<String, String>();
    List<KeyValue<String, String>> resultMap = null;
    try {
        resultMap = result.get(expireTimeLong, TimeUnit.SECONDS);
    }
    catch (Exception e) {
        lcr.setRunState(false);
        return lcr;
    }

    for (int i = 0; i < resultMap.size(); i++) {
        if (resultMap.get(i).hasValue() == true) {
            results.put(resultMap.get(i).getKey(), resultMap.get(i).getValue());
        }
    }
    lcr.setResult(results);
    lcr.setRunState(true);
    return lcr;
}
 
Example #7
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> hmget(K key, K... fields) {
  Span span = helper.buildSpan("hmget", key);
  try {
    return commands.hmget(key, fields);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #8
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> mget(K... keys) {
  Span span = helper.buildSpan("mget", keys);
  try {
    return commands.mget(keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #9
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> blpop(long timeout, K... keys) {
  Span span = helper.buildSpan("blpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.blpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #10
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> brpop(long timeout, K... keys) {
  Span span = helper.buildSpan("brpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.brpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #11
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> blpop(long timeout, K... keys) {
  Span span = helper.buildSpan("blpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.blpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #12
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> mget(K... keys) {
  Span span = helper.buildSpan("mget", keys);
  try {
    return commands.mget(keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #13
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> blpop(long timeout, K... keys) {
  Span span = helper.buildSpan("blpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.blpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #14
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> mget(K... keys) {
  Span span = helper.buildSpan("mget", keys);
  try {
    return commands.mget(keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #15
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> hmget(K key, K... fields) {
  Span span = helper.buildSpan("hmget", key);
  try {
    return commands.hmget(key, fields);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #16
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> hmget(K key, K... fields) {
  Span span = helper.buildSpan("hmget", key);
  try {
    return commands.hmget(key, fields);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #17
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> mget(K... keys) {
  Span span = helper.buildSpan("mget", keys);
  try {
    return commands.mget(keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #18
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> blpop(long timeout, K... keys) {
  Span span = helper.buildSpan("blpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.blpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #19
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> brpop(long timeout, K... keys) {
  Span span = helper.buildSpan("brpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.brpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #20
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> brpop(long timeout, K... keys) {
  Span span = helper.buildSpan("brpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.brpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #21
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> blpop(long timeout, K... keys) {
  Span span = helper.buildSpan("blpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.blpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #22
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> hmget(K key, K... fields) {
  Span span = helper.buildSpan("hmget", key);
  try {
    return commands.hmget(key, fields);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #23
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> mget(K... keys) {
  Span span = helper.buildSpan("mget", keys);
  try {
    return commands.mget(keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #24
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> blpop(long timeout, K... keys) {
  Span span = helper.buildSpan("blpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.blpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #25
Source File: TracingRedisAdvancedClusterCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public KeyValue<K, V> brpop(long timeout, K... keys) {
  Span span = helper.buildSpan("brpop", keys);
  span.setTag("timeout", timeout);
  try {
    return commands.brpop(timeout, keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #26
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> mget(K... keys) {
  Span span = helper.buildSpan("mget", keys);
  try {
    return commands.mget(keys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #27
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<KeyValue<K, V>> hmget(K key, K... fields) {
  Span span = helper.buildSpan("hmget", key);
  try {
    return commands.hmget(key, fields);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #28
Source File: TracingRedisCommands.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public KeyValue<K, ScoredValue<V>> bzpopmax(long timeout, K... keys) {
  Span span = helper.buildSpan("bzpopmax", keys);
  span.setTag("timeout", timeout);
  return helper.decorate(span, () -> commands.bzpopmax(timeout, keys));
}
 
Example #29
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public RedisFuture<KeyValue<K, V>> brpop(long timeout, K... keys) {
  Span span = helper.buildSpan("brpop", keys);
  span.setTag("timeout", timeout);
  return prepareRedisFuture(commands.brpop(timeout, keys), span);
}
 
Example #30
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public RedisFuture<KeyValue<K, ScoredValue<V>>> bzpopmin(long timeout, K... keys) {
  Span span = helper.buildSpan("bzpopmin", keys);
  span.setTag("timeout", timeout);
  return prepareRedisFuture(commands.bzpopmin(timeout, keys), span);
}