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

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

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

Jedis.hdel介绍

[英]Remove the specified field from an hash stored at key.

Time complexity: O(1)
[中]从存储在密钥处的哈希中删除指定字段。
时间复杂度:O(1)

代码示例

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

@Override
 public Long execute(Jedis connection) {
  return connection.hdel(key, field);
 }
}.run(key);

代码示例来源:origin: apache/storm

@Override
public Long hdel(byte[] key, byte[]... fields) {
  return jedis.hdel(key, fields);
}

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

@Override
 public Long execute(Jedis connection) {
  return connection.hdel(key, field);
 }
}.runBinary(key);

代码示例来源:origin: yu199195/hmily

@Override
public Long hdel(final String key, final String item) {
  try (Jedis jedis = jedisPool.getResource()) {
    return jedis.hdel(key, item);
  }
}

代码示例来源:origin: yu199195/Raincat

@Override
public Long hdel(final String key, final String item) {
  try (Jedis jedis = jedisPool.getResource()) {
    return jedis.hdel(key, item);
  }
}

代码示例来源:origin: yu199195/myth

@Override
public Long hdel(final String key, final String item) {
  try (Jedis jedis = jedisPool.getResource()) {
    return jedis.hdel(key, item);
  }
}

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

@Override
public Long hdel(byte[] key, byte[]... fields) {
 Jedis j = getShard(key);
 return j.hdel(key, fields);
}

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

@Override
public Long hdel(String key, String... fields) {
 Jedis j = getShard(key);
 return j.hdel(key, fields);
}

代码示例来源:origin: yu199195/hmily

@Override
public Long hdel(final String key, final String item) {
  try (Jedis jedis = jedisSentinelPool.getResource()) {
    return jedis.hdel(key, item);
  }
}

代码示例来源:origin: signalapp/Signal-Server

public void remove(byte[] token) {
 try (Jedis jedis = redisPool.getWriteResource()) {
  jedis.hdel(DIRECTORY_KEY, token);
 }
}

代码示例来源:origin: yu199195/Raincat

@Override
public Long hdel(final String key, final String item) {
  try (Jedis jedis = jedisSentinelPool.getResource()) {
    return jedis.hdel(key, item);
  }
}

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

@Override
protected void command() {
  jedis.select(db);
  jedis.hdel(key, fields);
  
}
@Override

代码示例来源:origin: yu199195/myth

@Override
public Long hdel(final String key, final String item) {
  try (Jedis jedis = jedisSentinelPool.getResource()) {
    return jedis.hdel(key, item);
  }
}

代码示例来源:origin: apache/incubator-dubbo

private void clean(Jedis jedis) {
  Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
  if (CollectionUtils.isNotEmpty(keys)) {
    for (String key : keys) {
      Map<String, String> values = jedis.hgetAll(key);
      if (CollectionUtils.isNotEmptyMap(values)) {
        boolean delete = false;
        long now = System.currentTimeMillis();
        for (Map.Entry<String, String> entry : values.entrySet()) {
          URL url = URL.valueOf(entry.getKey());
          if (url.getParameter(Constants.DYNAMIC_KEY, true)) {
            long expire = Long.parseLong(entry.getValue());
            if (expire < now) {
              jedis.hdel(key, entry.getKey());
              delete = true;
              if (logger.isWarnEnabled()) {
                logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now));
              }
            }
          }
        }
        if (delete) {
          jedis.publish(key, Constants.UNREGISTER);
        }
      }
    }
  }
}

代码示例来源:origin: apache/incubator-dubbo

private void clean(Jedis jedis) {
  Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
  if (CollectionUtils.isNotEmpty(keys)) {
    for (String key : keys) {
      Map<String, String> values = jedis.hgetAll(key);
      if (CollectionUtils.isNotEmptyMap(values)) {
        boolean delete = false;
        long now = System.currentTimeMillis();
        for (Map.Entry<String, String> entry : values.entrySet()) {
          URL url = URL.valueOf(entry.getKey());
          if (url.getParameter(Constants.DYNAMIC_KEY, true)) {
            long expire = Long.parseLong(entry.getValue());
            if (expire < now) {
              jedis.hdel(key, entry.getKey());
              delete = true;
              if (logger.isWarnEnabled()) {
                logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now));
              }
            }
          }
        }
        if (delete) {
          jedis.publish(key, Constants.UNREGISTER);
        }
      }
    }
  }
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public void doUnregister(URL url) {
  String key = toCategoryPath(url);
  String value = url.toFullString();
  RpcException exception = null;
  boolean success = false;
  for (Map.Entry<String, JedisPool> entry : jedisPools.entrySet()) {
    JedisPool jedisPool = entry.getValue();
    try {
      try (Jedis jedis = jedisPool.getResource()) {
        jedis.hdel(key, value);
        jedis.publish(key, Constants.UNREGISTER);
        success = true;
        if (!replicate) {
          break; //  If the server side has synchronized data, just write a single machine
        }
      }
    } catch (Throwable t) {
      exception = new RpcException("Failed to unregister service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
    }
  }
  if (exception != null) {
    if (success) {
      logger.warn(exception.getMessage(), exception);
    } else {
      throw exception;
    }
  }
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public void doUnregister(URL url) {
  String key = toCategoryPath(url);
  String value = url.toFullString();
  RpcException exception = null;
  boolean success = false;
  for (Map.Entry<String, JedisPool> entry : jedisPools.entrySet()) {
    JedisPool jedisPool = entry.getValue();
    try {
      try (Jedis jedis = jedisPool.getResource()) {
        jedis.hdel(key, value);
        jedis.publish(key, Constants.UNREGISTER);
        success = true;
        if (!replicate) {
          break; //  If the server side has synchronized data, just write a single machine
        }
      }
    } catch (Throwable t) {
      exception = new RpcException("Failed to unregister service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
    }
  }
  if (exception != null) {
    if (success) {
      logger.warn(exception.getMessage(), exception);
    } else {
      throw exception;
    }
  }
}

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

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

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

/**
 * 删除哈希表 key 中的一个或多个指定域,不存在的域将被忽略。
 */
public Long hdel(Object key, Object... fields) {
  Jedis jedis = getJedis();
  try {
    return jedis.hdel(keyToBytes(key), fieldsToBytesArray(fields));
  }
  finally {close(jedis);}
}

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

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

相关文章

Jedis类方法