當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。