當前位置: 首頁>>代碼示例>>Java>>正文


Java Jedis.lrange方法代碼示例

本文整理匯總了Java中redis.clients.jedis.Jedis.lrange方法的典型用法代碼示例。如果您正苦於以下問題:Java Jedis.lrange方法的具體用法?Java Jedis.lrange怎麽用?Java Jedis.lrange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis.clients.jedis.Jedis的用法示例。


在下文中一共展示了Jedis.lrange方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerService

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 注冊服務
 * 將服務URL保存到redis的list集合中
 * @param serviceUrl:http://192.168.0.100:8080/工程名 
 */
public boolean registerService(String serviceUrl){
	
	Jedis jedis = JedisTemplate.getJedis();
	Long len;
	Long tmp;
	try{
		len = jedis.llen(onlineServices);
		tmp = len;
		List<String> services = jedis.lrange(onlineServices, 0, -1);
		if(!services.contains(serviceUrl)){
			len = jedis.rpush("onlineServices", serviceUrl);
			if(tmp + 1 == len){
				return true;
			}
		}
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		jedis.close();
	}
	
	return false;
	
}
 
開發者ID:smxc,項目名稱:garlicts,代碼行數:30,代碼來源:SimpleServiceUrlRoute.java

示例2: getVByList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 往redis裏取list
 * 
 * @param <T>
 * @param listKey
 * @param start
 * @param end
 * @param requiredType
 * @return
 */
@SuppressWarnings("unchecked")
public <T> List<T> getVByList(String listKey,int start,int end,Class<T> requiredType) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		List<T> list = new ArrayList<T>();
		List<byte[]> xx = jds.lrange(listKey.getBytes(),start,end);
		for (byte[] bs : xx) {
			T t = SerializeUtil.deserialize(bs, requiredType);
			list.add(t);
		}
		return list;
	} catch (Exception e) {
		throw e;
	} finally {
		if(jds != null)
		{
			jds.close();
		}
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:33,代碼來源:RedisManager.java

示例3: getAllService

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取所有服務列表
 */
public List<String> getAllService(){
	
	Jedis jedis = JedisTemplate.getJedis();
	List<String> services = null;
	try{
		services = jedis.lrange(onlineServices, 0, -1);
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		jedis.close();
	}
	
	return services;
	
}
 
開發者ID:smxc,項目名稱:garlicts,代碼行數:19,代碼來源:SimpleServiceUrlRoute.java

示例4: getList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取List緩存
 *
 * @param key 鍵
 * @return 值
 */
public static List<String> getList(String key) {
	List<String> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			value = jedis.lrange(key, 0, -1);
			logger.debug("getList {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:23,代碼來源:JedisUtils.java

示例5: getObjectList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取List緩存
 *
 * @param key 鍵
 * @return 值
 */
public static List<Object> getObjectList(String key) {
	List<Object> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(getBytesKey(key))) {
			List<byte[]> list = jedis.lrange(getBytesKey(key), 0, -1);
			value = Lists.newArrayList();
			for (byte[] bs : list) {
				value.add(toObject(bs));
			}
			logger.debug("getObjectList {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getObjectList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:27,代碼來源:JedisUtils.java

示例6: lrange

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public List<String> lrange(String key, int start, int stop) {
	Jedis jedis = null;
	boolean success = true;
	List<String> ret = null;
	try {
		jedis = jedisPool.getResource();
		if (jedis == null) {
			success = false;
			return ret;
		}
		ret = jedis.lrange(key, start, stop);

	} catch (Exception e) {
		success = false;
		returnBrokenResource(jedis, "lrange", e);
	} finally {
		releaseReidsSource(success, jedis);
	}
	return ret;
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:21,代碼來源:RedisService.java

示例7: lrange

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public List<String> lrange(String key) {
    Jedis jedis = null;
    try {
        jedis = getJedis();
        if (jedis == null) {
            logger.error("get jedis fail");
        }
        List<String> list = jedis.lrange(key, 0, 50);
        return list;
    } catch (JedisConnectionException e) {
        if (jedis != null) {
            jedis.close();
        }
    } finally {
        returnJedisResource(jedis);
    }
    return null;
}
 
開發者ID:Zephery,項目名稱:newblog,代碼行數:19,代碼來源:JedisUtil.java

示例8: getActiveSessions

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取會話列表
 * @param offset
 * @param limit
 * @return
 */
public Map getActiveSessions(int offset, int limit) {
    Map sessions = new HashMap();
    Jedis jedis = RedisUtil.getJedis();
    // 獲取在線會話總數
    long total = jedis.llen(ZHENG_UPMS_SERVER_SESSION_IDS);
    // 獲取當前頁會話詳情
    List<String> ids = jedis.lrange(ZHENG_UPMS_SERVER_SESSION_IDS, offset, (offset + limit - 1));
    List<Session> rows = new ArrayList<>();
    for (String id : ids) {
        String session = RedisUtil.get(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + id);
        // 過濾redis過期session
        if (null == session) {
            RedisUtil.lrem(ZHENG_UPMS_SERVER_SESSION_IDS, 1, id);
            total = total - 1;
            continue;
        }
         rows.add(SerializableUtil.deserialize(session));
    }
    jedis.close();
    sessions.put("total", total);
    sessions.put("rows", rows);
    return sessions;
}
 
開發者ID:youngMen1,項目名稱:-Spring-SpringMVC-Mybatis-,代碼行數:30,代碼來源:UpmsSessionDao.java

示例9: getList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取List緩存
 * @param key 鍵
 * @return 值
 */
public static List<String> getList(String key) {
	List<String> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			value = jedis.lrange(key, 0, -1);
			logger.debug("getList {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:22,代碼來源:JedisUtils.java

示例10: getObjectList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取List緩存
 * @param key 鍵
 * @return 值
 */
public static List<Object> getObjectList(String key) {
	List<Object> value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(getBytesKey(key))) {
			List<byte[]> list = jedis.lrange(getBytesKey(key), 0, -1);
			value = Lists.newArrayList();
			for (byte[] bs : list){
				value.add(toObject(bs));
			}
			logger.debug("getObjectList {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("getObjectList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:26,代碼來源:JedisUtils.java

示例11: getActiveSessions

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取會話列表
 * @param offset
 * @param limit
 * @return
 */
public Map getActiveSessions(int offset, int limit) {
    Map sessions = new HashMap();
    Jedis jedis = RedisUtil.getJedis();
    // 獲取在線會話總數
    long total = jedis.llen(LAMBO_UPMS_SERVER_SESSION_IDS);
    // 獲取當前頁會話詳情
    List<String> ids = jedis.lrange(LAMBO_UPMS_SERVER_SESSION_IDS, offset, (offset + limit - 1));
    List<Session> rows = new ArrayList<>();
    for (String id : ids) {
        String session = RedisUtil.get(LAMBO_UPMS_SHIRO_SESSION_ID + "_" + id);
        // 過濾redis過期session
        if (null == session) {
            RedisUtil.lrem(LAMBO_UPMS_SERVER_SESSION_IDS, 1, id);
            total = total - 1;
            continue;
        }
         rows.add(SerializableUtil.deserialize(session));
    }
    jedis.close();
    sessions.put("total", total);
    sessions.put("rows", rows);
    return sessions;
}
 
開發者ID:sunzhen086,項目名稱:lambo,代碼行數:30,代碼來源:UpmsSessionDao.java

示例12: lrange

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public List<String> lrange(String key, long start, long end) {
    Jedis jedis = null;
    List<String> res = null;
    try {
        jedis = pool.getResource();
        res = jedis.lrange(key, start, end);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
開發者ID:wxiaoqi,項目名稱:ace-cache,代碼行數:16,代碼來源:RedisServiceImpl.java

示例13: index

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 此操作可能消耗資源較多,因為需要傳遞所有數據到內存,如果遇到問題在考慮優化吧
 *
 * @param queueID 隊列id
 * @param key     待查找的資源
 * @return 該資源當前在隊列的位置, 如果該資源在隊列中不存在, 則返回-1
 */
@Override
public long index(String queueID, String key) {
    if (!lockQueue(queueID)) {
        return -1;
    }
    Jedis jedis = jedisPool.getResource();
    try {
        List<String> queue = jedis.lrange(makePoolQueueKey(queueID), 0, -1);
        return queue.indexOf(key);
    } finally {
        IOUtils.closeQuietly(jedis);
        unLockQueue(queueID);
    }
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:22,代碼來源:JedisQueueStore.java

示例14: sliceQueue

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
private List<String> sliceQueue(String queueID) {
    if (!lockQueue(queueID)) {
        throw new IllegalStateException("error for acquire queue lock for queue :" + queueID);
    }
    @Cleanup Jedis jedis = jedisPool.getResource();
    try {
        return jedis.lrange(makeSliceQueueKey(queueID), 0, -1);
    } finally {
        unLockQueue(queueID);
    }
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:12,代碼來源:JedisSegmentQueueStore.java


注:本文中的redis.clients.jedis.Jedis.lrange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。