当前位置: 首页>>代码示例>>Java>>正文


Java Jedis.hkeys方法代码示例

本文整理汇总了Java中redis.clients.jedis.Jedis.hkeys方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.hkeys方法的具体用法?Java Jedis.hkeys怎么用?Java Jedis.hkeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.Jedis的用法示例。


在下文中一共展示了Jedis.hkeys方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addBatch

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public void addBatch(String queueID, Set<ResourceItem> resourceItems) {
    if (!lockQueue(queueID)) {
        return;
    }
    final Jedis jedis = jedisPool.getResource();
    final String dataKey = makeDataKey(queueID);
    try {
        final Set<String> hkeys = jedis.hkeys(dataKey);
        Set<ResourceItem> filterSet = Sets.filter(resourceItems, new Predicate<ResourceItem>() {
            @Override
            public boolean apply(ResourceItem input) {
                return !hkeys.contains(input.getKey());
            }
        });

        String poolQueueKey = makePoolQueueKey(queueID);
        for (ResourceItem resourceItem : filterSet) {
            jedis.hset(dataKey, resourceItem.getKey(), JSONObject.toJSONString(resourceItem));
            jedis.rpush(poolQueueKey, resourceItem.getKey());
        }
    } finally {
        IOUtils.closeQuietly(jedis);
        unLockQueue(queueID);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:27,代码来源:JedisQueueStore.java

示例2: notExisted

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public Set<String> notExisted(String queueID, Set<String> resourceItemKeys) {
    if (!lockQueue(queueID)) {
        return Collections.emptySet();
    }
    Jedis jedis = jedisPool.getResource();
    try {
        final Set<String> hkeys = jedis.hkeys(makeDataKey(queueID));
        return Sets.filter(resourceItemKeys, new Predicate<String>() {
            @Override
            public boolean apply(String input) {
                return !hkeys.contains(input);
            }
        });
    } finally {
        IOUtils.closeQuietly(jedis);
        unLockQueue(queueID);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:20,代码来源:JedisQueueStore.java

示例3: notExisted

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public Set<String> notExisted(String queueID, Set<String> resourceItemKeys) {
    if (!lockQueue(queueID)) {
        return Collections.emptySet();
    }
    @Cleanup Jedis jedis = jedisPool.getResource();
    try {
        final Set<String> existedSet = jedis.hkeys(makeDataKey(queueID));
        return Sets.filter(resourceItemKeys, new Predicate<String>() {
            @Override
            public boolean apply(String input) {
                return !existedSet.contains(input);
            }
        });
    } finally {
        unLockQueue(queueID);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:19,代码来源:JedisSegmentQueueStore.java

示例4: doRequest

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
protected int doRequest(Jedis jedis, String redisAddress) {
  Set<byte[]> fields = jedis.hkeys(key.getBytes());
  redisFields[index] = fields;

  if (CollectionUtils.isEmpty(fields)) {
    String verbose = String.format("get fields [%s] from [%s] is empty", key, redisAddress);
    LOGGER.debug(verbose);
    return 1;
  }

  return 0;
}
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:14,代码来源:RedisHKeys.java

示例5: hkeys

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public Set<String> hkeys(String key) {
    Jedis jedis = null;
    Set<String> res = null;
    try {
        jedis = pool.getResource();
        res = jedis.hkeys(key);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
开发者ID:wxiaoqi,项目名称:ace-cache,代码行数:16,代码来源:RedisServiceImpl.java

示例6: addBatch

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public void addBatch(String queueID, Set<ResourceItem> resourceItems) {
    if (!lockQueue(queueID)) {
        return;
    }
    @Cleanup Jedis jedis = jedisPool.getResource();
    final String dataKey = makeDataKey(queueID);
    try {
        final Set<String> hkeys = jedis.hkeys(dataKey);
        Set<ResourceItem> filterSet = Sets.filter(resourceItems, new Predicate<ResourceItem>() {
            @Override
            public boolean apply(ResourceItem input) {
                return !hkeys.contains(input.getKey());
            }
        });
        List<String> sliceQueue = sliceQueue(queueID);
        Set<String> newSlices = Sets.newHashSet();
        long index = size(queueID) + 1;
        String tailSlice = null;
        for (ResourceItem resourceItem : filterSet) {
            jedis.hset(dataKey, resourceItem.getKey(), JSONObject.toJSONString(resourceItem));
            String sliceID = String.valueOf(blockID(index));
            if (sliceID.equals(tailSlice) || sliceQueue.contains(sliceID)) {
                sliceID = sliceQueue.get(sliceQueue.size() - 1);
                tailSlice = sliceID;
            } else if (!newSlices.contains(sliceID)) {
                jedis.rpush(makeSliceQueueKey(queueID), sliceID);
                newSlices.add(sliceID);
            }
            jedis.rpush(makePoolQueueKey(queueID, sliceID), resourceItem.getKey());
            index++;
        }
    } finally {
        unLockQueue(queueID);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:37,代码来源:JedisSegmentQueueStore.java

示例7: testJedis

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void testJedis() {

  String host = "localhost";
  int port = 6379;
  String key = "test_xxx";
  String keyNotExist = "test_not_exist";

  String field = "field_1";
  String value = "value_1";

  String fieldNotExist = "field_not_exist";

  JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
  jedisPoolConfig.setMaxTotal(Config.getInstance().getJedisPoolMax());

  JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, Config.getInstance().getJedisSocketTimeoutMs(), Config.getInstance().getRedisPassword());
  Jedis jedis = jedisPool.getResource();

  jedis.hset(key.getBytes(), field.getBytes(), value.getBytes());

  // hgetAll
  Map<byte[], byte[]> result = jedis.hgetAll(key.getBytes());
  Assert.assertTrue(MapUtils.isNotEmpty(result));

  result = jedis.hgetAll(keyNotExist.getBytes());
  Assert.assertTrue(MapUtils.isEmpty(result));

  // hkeys
  Set<byte[]> redisKeys = jedis.hkeys(key.getBytes());
  Assert.assertTrue(CollectionUtils.isNotEmpty(redisKeys));

  redisKeys = jedis.hkeys(keyNotExist.getBytes());
  Assert.assertTrue(CollectionUtils.isEmpty(redisKeys));


  // hget
  byte[] redisValue = jedis.hget(key.getBytes(), field.getBytes());
  Assert.assertTrue(!ArrayUtils.isEmpty(redisValue));

  redisValue = jedis.hget(key.getBytes(), fieldNotExist.getBytes());
  Assert.assertTrue(ArrayUtils.isEmpty(redisValue));

  redisValue = jedis.hget(keyNotExist.getBytes(), field.getBytes());
  Assert.assertTrue(ArrayUtils.isEmpty(redisValue));

}
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:48,代码来源:RedisAccessTest.java


注:本文中的redis.clients.jedis.Jedis.hkeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。