redis.clients.jedis.Jedis.type()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中redis.clients.jedis.Jedis.type()方法的一些代码示例,展示了Jedis.type()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.type()方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:type

Jedis.type介绍

[英]Return the type of the value stored at key in form of a string. The type can be one of "none", "string", "list", "set". "none" is returned if the key does not exist. Time complexity: O(1)
[中]以字符串形式返回存储在键处的值的类型。类型可以是“无”、“字符串”、“列表”、“集”之一。如果密钥不存在,则返回“无”。时间复杂度:O(1)

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
 public String execute(Jedis connection) {
  return connection.type(key);
 }
}.run(key);

代码示例来源:origin: sohutv/cachecloud

@Override
 public String execute(Jedis connection) {
  return connection.type(key);
 }
}.runBinary(key);

代码示例来源:origin: sohutv/cachecloud

@Override
public String type(byte[] key) {
 Jedis j = getShard(key);
 return j.type(key);
}

代码示例来源:origin: caoxinyu/RedisClient

protected NodeType getValueType(String key) {
  String type = jedis.type(key);
  NodeType nodeType = null;
  if (type.equals("string"))
    nodeType = NodeType.STRING;
  else if (type.equals("hash"))
    nodeType = NodeType.HASH;
  else if (type.equals("list"))
    nodeType = NodeType.LIST;
  else if (type.equals("set"))
    nodeType = NodeType.SET;
  else
    nodeType = NodeType.SORTEDSET;
  return nodeType;
}

代码示例来源:origin: sohutv/cachecloud

@Override
public String type(String key) {
 Jedis j = getShard(key);
 return j.type(key);
}

代码示例来源:origin: Netflix/conductor

@Override
public String type(String key) {
 Jedis jedis = null;
 try {
  jedis = jedisPool.getResource();
  return jedis.type(key);
 } finally {
  if (jedis != null)
   jedis.close();
 }
}

代码示例来源:origin: caoxinyu/RedisClient

protected long getSize(String key) {
  Long size;
  String type = jedis.type(key);
  if (type.equals("string"))
    size = (long) 1;
  else if (type.equals("hash"))
    size = jedis.hlen(key);
  else if (type.equals("list"))
    size = jedis.llen(key);
  else if (type.equals("set"))
    size = jedis.scard(key);
  else
    size = jedis.zcard(key);
  return size;
}

代码示例来源:origin: jfinal/jfinal

/**
 * 返回 key 所储存的值的类型。
 */
public String type(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.type(keyToBytes(key));
  }
  finally {close(jedis);}
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public DataType type(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(
          connection.newJedisResult(connection.getRequiredPipeline().type(key), JedisConverters.stringToDataType()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().type(key),
          JedisConverters.stringToDataType()));
      return null;
    }
    return JedisConverters.toDataType(connection.getJedis().type(key));
  } catch (Exception ex) {
    throw connection.convertJedisAccessException(ex);
  }
}

代码示例来源:origin: io.leopard/leopard-redis

@Override
  public Object execute(Jedis jedis) {
    return jedis.type(key);
  }
});

代码示例来源:origin: gresrun/jesque

/**
 * Determines if the queue identified by the given key is a delayed queue.
 * 
 * @param jedis
 *            connection to Redis
 * @param key
 *            the key that identifies a queue
 * @return true if the key identifies a delayed queue, false otherwise
 */
public static boolean isDelayedQueue(final Jedis jedis, final String key) {
  return ZSET.equalsIgnoreCase(jedis.type(key));
}

代码示例来源:origin: gresrun/jesque

/**
 * Determines if the queue identified by the given key is used.
 * 
 * @param jedis
 *            connection to Redis
 * @param key
 *            the key that identifies a queue
 * @return true if the key is used, false otherwise
 */
public static boolean isKeyUsed(final Jedis jedis, final String key) {
  return !NONE.equalsIgnoreCase(jedis.type(key));
}

代码示例来源:origin: gresrun/jesque

/**
 * Determines if the queue identified by the given key can be used as a delayed queue.
 * 
 * @param jedis
 *            connection to Redis
 * @param key
 *            the key that identifies a queue
 * @return true if the key already is a delayed queue or is not currently used, false otherwise
 */
public static boolean canUseAsDelayedQueue(final Jedis jedis, final String key) {
  final String type = jedis.type(key);
  return (ZSET.equalsIgnoreCase(type) || NONE.equalsIgnoreCase(type));
}

代码示例来源:origin: dimovelev/metrics-sampler

protected Map<String, String> determineTypes(Set<String> keys) {
    final Map<String, String> result = new HashMap<>();
    for (final String key : keys) {
      result.put(key, jedis.type(key));
    }
    return Collections.unmodifiableMap(result);
  }
}

代码示例来源:origin: com.github.sogyf/goja-mvt

@Override
  public String action(Jedis jedis) {
    return jedis.type(SafeEncoder.encode(key));
  }
});

代码示例来源:origin: lordofthejars/nosql-unit

private static void checkType(Jedis jedis, Object expectedKey, byte[] key, String expectedType) throws Error {
  String type = jedis.type(key);
  if ("none".equals(type)) {
    throw FailureHandler.createFailure("Key %s is not found.", expectedKey);
  }
  if (!expectedType.equals(type)) {
    throw FailureHandler.createFailure("Element with key %s is not a %s.", expectedKey, expectedType);
  }
}

代码示例来源:origin: com.lordofthejars/nosqlunit-redis

private static void checkType(Jedis jedis, Object expectedKey, byte[] key, String expectedType) throws Error {
  String type = jedis.type(key);
  if ("none".equals(type)) {
    throw FailureHandler.createFailure("Key %s is not found.", expectedKey);
  }
  if (!expectedType.equals(type)) {
    throw FailureHandler.createFailure("Element with key %s is not a %s.", expectedKey, expectedType);
  }
}

代码示例来源:origin: yangfuhai/jboot

/**
 * 返回 key 所储存的值的类型。
 */
public String type(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.type(keyToBytes(key));
  } finally {
    returnResource(jedis);
  }
}

代码示例来源:origin: com.jfinal/jfinal

/**
 * 返回 key 所储存的值的类型。
 */
public String type(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.type(keyToBytes(key));
  }
  finally {close(jedis);}
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.getArgMap().get("key").toString();
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  String type = Redis.call(cacheConfigBean, jedis -> jedis.type(key));
  handler.handle(UnitResponse.createSuccess(type));
}

相关文章

Jedis类方法