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


Java Jedis.hgetAll方法代码示例

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


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

示例1: test_jedis_tracer

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void test_jedis_tracer() throws Exception {
    Brave.Builder builder = new Brave.Builder("jedis-interceptor-test");
    builder.spanCollector(HttpSpanCollector.create("http://192.168.150.132:9411", new EmptySpanCollectorMetricsHandler()));
    builder.traceSampler(Sampler.ALWAYS_SAMPLE);
    Brave brave = builder.build();
    JaRedisInterceptor.setClientTracer(brave.clientTracer());

    JedisPoolConfig config = new JedisPoolConfig();
    JaRedisPool proxyPool = new JaRedisPool(config, "127.0.0.1", 6379);
    Jedis jedis = proxyPool.getResource();
    jedis.set("hello", "world");
    Assert.assertEquals(jedis.get("hello"), "world");
    jedis.hgetAll("hello-map");
    jedis.close();
    // sleep 3s in case spanCollector not flushed
    Thread.sleep(3000);
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:19,代码来源:TestJedisProxyPool.java

示例2: getMap

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 获取Map缓存
 *
 * @param key 键
 * @return 值
 */
public static Map<String, String> getMap(String key) {
	Map<String, String> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			value = jedis.hgetAll(key);
			logger.debug("getMap {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getMap {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
开发者ID:funtl,项目名称:framework,代码行数:23,代码来源:JedisUtils.java

示例3: lookups

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public <T> List<T> lookups(Mcf mcf, Class<T> cls) {
	String key = mcf.buildRoot(super.nurl).getPrefixKey();
	Jedis jedis = null;
	try {
		jedis = jedisPool.getResource();
		Map<String, String> dataMap = jedis.hgetAll(key);
		List<T> list = new ArrayList<T>();
		for (String tempJson : dataMap.values()) {
			list.add(super.json2Obj(tempJson, cls));
		}

		return list;
	} catch (Exception e) {
		logger.error("The pulls conf exception.", e);
	} finally {
		if (jedis != null) {
			jedis.close();
		}
	}

	return null;
}
 
开发者ID:yu120,项目名称:coon,代码行数:24,代码来源:RedisMconf.java

示例4: queryAll

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public List<ResourceItem> queryAll(String queueID) {
    lockQueue(queueID);
    Jedis jedis = jedisPool.getResource();
    try {
        final Map<String, String> map = jedis.hgetAll(makeDataKey(queueID));
        return Lists.transform(jedis.lrange(makePoolQueueKey(queueID), 0, -1), new Function<String, ResourceItem>() {
            @Override
            public ResourceItem apply(String input) {
                return JSONObject.toJavaObject(JSONObject.parseObject(map.get(input)), ResourceItem.class);
            }
        });
    } finally {
        IOUtils.closeQuietly(jedis);
        unLockQueue(queueID);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:18,代码来源:JedisQueueStore.java

示例5: getHash

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public Map<String, String> getHash(String key) {
    Jedis jedis = null;
    Map<String, String> result = null;
    try {
        jedis = getJedis();
        if (jedis != null) {
            result = jedis.hgetAll(key);
        } else {
            logger.error("hgetall opt connection null error!");
        }
    } catch (JedisConnectionException e) {
        if (jedis != null) {
            jedis.close();
            jedis = null;
        }
        logger.error("hgetall value connect error:", e);
    } finally {
        returnJedisResource(jedis);
    }
    return result;
}
 
开发者ID:Zephery,项目名称:newblog,代码行数:22,代码来源:JedisUtil.java

示例6: jedistest

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@GET
@Path("jedistest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String jedistest() {

    System.out.println("TEST Jedis ======================================================");
    Jedis jedis = new Jedis("localhost", 6379);
    jedis.set("foo", "bar");

    jedis.get("foo");

    jedis.lpush("lll", "a");
    jedis.lpush("lll", "b");
    jedis.lpush("lll", "c");
    jedis.lpop("lll");
    jedis.lpop("lll");
    jedis.lpop("lll");

    jedis.hset("mmm", "abc", "123");
    jedis.hset("mmm", "def", "456");
    jedis.hgetAll("mmm");

    jedis.close();
    return "jedistest";
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:26,代码来源:RedisService.java

示例7: getObjectFromHash

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T getObjectFromHash(String key, Class<?> clazz, int seconds) {
	Jedis jedis = null;
	boolean success = true;
	Object ret = null;
	try {
		if (clazz == null) {
			success = false;
			return null;
		}
		jedis = jedisPool.getResource();
		if (jedis == null) {
			success = false;
			return null;
		}
		Map<String, String> map = jedis.hgetAll(key);
		if (map != null && map.size() > 0) {
			Object obj = clazz.newInstance();
			if (obj != null) {
				ret = ObjectUtils.getObjFromMap(map, obj);
			}
			if (seconds >= 0) {
				jedis.expire(key, seconds);
			}
		}
	} catch (Exception e) {
		success = false;
		returnBrokenResource(jedis, "getObjectFromHash:" + key, e);
	} finally {
		releaseReidsSource(success, jedis);
	}
	return (T) ret;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:34,代码来源:RedisService.java

示例8: loadParty

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public void loadParty(UUID party)
{
    Jedis jedis = api.getBungeeResource();
    String leader = jedis.get("party:" + party + ":lead");
    Map<String, String> data = jedis.hgetAll("party:" + party + ":members");
    jedis.close();
    if (leader == null)
        return;

    Party partie = new Party(party, UUID.fromString(leader), data.keySet().stream().map(UUID::fromString).collect(Collectors.toList()));
    parties.put(party, partie);
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:13,代码来源:PartiesManager.java

示例9: clean

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private void clean(Jedis jedis) {
    Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
    if (keys != null && keys.size() > 0) {
        for (String key : keys) {
            Map<String, String> values = jedis.hgetAll(key);
            if (values != null && values.size() > 0) {
                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);
                }
            }
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:29,代码来源:RedisRegistry.java

示例10: getHashAllFieldCache

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public Map<String, String> getHashAllFieldCache(String key) {
    Jedis jedis = null;

    Map var3;
    try {
        jedis = pool.getResource();
        var3 = jedis.hgetAll(key);
    } catch (Exception var7) {
        throw new RuntimeException(var7);
    } finally {
        pool.returnResourceObject(jedis);
    }

    return var3;
}
 
开发者ID:bitstd,项目名称:bitstd,代码行数:16,代码来源:RedisCacheWithoutCluster.java

示例11: clean

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private void clean(Jedis jedis) {
    Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
    if (keys != null && keys.size() > 0) {
        for (String key : keys) {
            Map<String, String> values = jedis.hgetAll(key);
            if (values != null && values.size() > 0) {
                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);
                }
            }
        }
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:29,代码来源:RedisRegistry.java

示例12: doRequest

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
protected int doRequest(Jedis jedis, String redisAddress) {
  Map<byte[], byte[]> redisData = jedis.hgetAll(key.getBytes());
  redisDataList[index] = redisData;
  if (MapUtils.isEmpty(redisData)) {
    String verbose = String.format("get all for key [%s] from [%s] is empty", key, redisAddress);
    LOGGER.debug(verbose);
    return 1;
  }
  return 0;
}
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:12,代码来源:RedisGetAll.java

示例13: jedispolltest

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@GET
@Path("jedispooltest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String jedispolltest() {

    System.out.println("TEST JedisPool ======================================================");
    JedisPoolConfig cfg = new JedisPoolConfig();
    cfg.setMaxTotal(5);
    cfg.setMaxIdle(1);
    cfg.setMaxWaitMillis(10000L);

    JedisPool jp = new JedisPool(cfg, "localhost", 6379);
    Jedis jedis = jp.getResource();

    jedis.set("foo", "bar");
    // jedis.close();
    jedis = jp.getResource();

    jedis.get("foo");
    // jedis.close();
    jedis = jp.getResource();

    jedis.lpush("lll", "a");
    jedis.lpush("lll", "b");
    jedis.lpush("lll", "c");
    jedis.lpop("lll");
    jedis.lpop("lll");
    jedis.lpop("lll");
    // jedis.close();
    jedis = jp.getResource();

    jedis.hset("mmm", "abc", "123");
    jedis.hset("mmm", "def", "456");
    jedis.hgetAll("mmm");

    jp.close();
    return "jedispooltest";
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:39,代码来源:RedisService.java

示例14: clean

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private void clean(Jedis jedis) {
    Set<String> keys = jedis.keys(root + Consts.ANY_VALUE);
    if (keys != null && keys.size() > 0) {
        for (String key : keys) {
            Map<String, String> values = jedis.hgetAll(key);
            if (values != null && values.size() > 0) {
                boolean delete = false;
                long now = System.currentTimeMillis();
                for (Map.Entry<String, String> entry : values.entrySet()) {
                	NURL nurl = NURL.valueOf(entry.getKey());
                    if (nurl.getParameter(Consts.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, Consts.UNREGISTER);
                }
            }
        }
    }
}
 
开发者ID:yu120,项目名称:coon,代码行数:29,代码来源:RedisMreg.java

示例15: doNotify

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private void doNotify(Jedis jedis, Collection<String> keys, URL url, Collection<NotifyListener> listeners) {
    if (keys == null || keys.size() == 0
            || listeners == null || listeners.size() == 0) {
        return;
    }
    long now = System.currentTimeMillis();
    List<URL> result = new ArrayList<URL>();
    List<String> categories = Arrays.asList(url.getParameter(Constants.CATEGORY_KEY, new String[0]));
    String consumerService = url.getServiceInterface();
    for (String key : keys) {
        if (! Constants.ANY_VALUE.equals(consumerService)) {
            String prvoiderService = toServiceName(key);
            if (! prvoiderService.equals(consumerService)) {
                continue;
            }
        }
        String category = toCategoryName(key);
        if (! categories.contains(Constants.ANY_VALUE) && ! categories.contains(category)) {
            continue;
        }
        List<URL> urls = new ArrayList<URL>();
        Map<String, String> values = jedis.hgetAll(key);
        if (values != null && values.size() > 0) {
            for (Map.Entry<String, String> entry : values.entrySet()) {
                URL u = URL.valueOf(entry.getKey());
                if (! u.getParameter(Constants.DYNAMIC_KEY, true)
                        || Long.parseLong(entry.getValue()) >= now) {
                    if (UrlUtils.isMatch(url, u)) {
                        urls.add(u);
                    }
                }
            }
        }
        if (urls.isEmpty()) {
            urls.add(url.setProtocol(Constants.EMPTY_PROTOCOL)
                    .setAddress(Constants.ANYHOST_VALUE)
                    .setPath(toServiceName(key))
                    .addParameter(Constants.CATEGORY_KEY, category));
        }
        result.addAll(urls);
        if (logger.isInfoEnabled()) {
            logger.info("redis notify: " + key + " = " + urls);
        }
    }
    if (result == null || result.size() == 0) {
        return;
    }
    for (NotifyListener listener : listeners) {
        notify(url, listener, result);
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:52,代码来源:RedisRegistry.java


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