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


Java Jedis.llen方法代碼示例

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


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

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

示例3: 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

示例4: getLenByList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取list長度
 * @param listKey
 * @return
 */
public Long getLenByList(String listKey) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		Long result = jds.llen(listKey.getBytes());
		return result;
	} catch (Exception e) {
		throw e;
	} finally {
		if(jds != null)
		{
			jds.close();
		}
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:22,代碼來源:RedisManager.java

示例5: 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

示例6: addIndex

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public boolean addIndex(String queueID, long index, ResourceItem e) {
    if (!lockQueue(queueID)) {
        return false;
    }
    remove(queueID, e.getKey());
    Jedis jedis = jedisPool.getResource();
    try {
        String poolQueueKey = makePoolQueueKey(queueID);
        Long length = jedis.llen(poolQueueKey);
        if (index <= length) {
            index = length - 1;
        }
        String position = jedis.lindex(makePoolQueueKey(queueID), index);
        if (isNil(position)) {
            jedis.rpush(poolQueueKey, e.getKey());
        } else {
            jedis.linsert(poolQueueKey, BinaryClient.LIST_POSITION.AFTER, position, e.getKey());
        }
        jedis.hset(makeDataKey(queueID), e.getKey(), JSONObject.toJSONString(e));
    } finally {
        IOUtils.closeQuietly(jedis);
        unLockQueue(queueID);
    }
    return true;
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:27,代碼來源:JedisQueueStore.java

示例7: getLeftCount

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public int getLeftCount(Task task) {
    Jedis jedis = jedisPool.getResource();
    try {
        Long size = jedis.llen(RedisKeys.getQueueKey(task));
        return size.intValue();
    } finally {
        jedis.close();
    }
}
 
開發者ID:brucezee,項目名稱:jspider,代碼行數:11,代碼來源:RedisScheduler.java

示例8: getLeftRequests

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public int getLeftRequests(String spiderName) {

    Jedis jedis = pool.getResource();
    try {
        Long size = jedis.llen(getQueueKey(spiderName));
        return size.intValue();
    } finally {
        pool.returnResource(jedis);
    }
}
 
開發者ID:fengzhizi715,項目名稱:NetDiscovery,代碼行數:12,代碼來源:RedisQueue.java

示例9: llen

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public Long llen(String key) {
    Jedis jedis = null;
    Long res = null;
    try {
        jedis = pool.getResource();
        res = jedis.llen(key);
    } catch (Exception e) {

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

示例10: getLeftRequestsCount

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public int getLeftRequestsCount(ISpider spider) {
    Jedis jedis = pool.getResource();
    try {
        Long size = jedis.llen(getQueueKey(spider));
        return size.intValue();
    } finally {
        jedis.close();
    }
}
 
開發者ID:xbynet,項目名稱:crawler,代碼行數:11,代碼來源:RedisScheduler.java

示例11: addIndex

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public boolean addIndex(String queueID, long index, ResourceItem e) {
    if (!lockQueue(queueID)) {
        return false;
    }
    @Cleanup Jedis jedis = jedisPool.getResource();
    try {
        remove(queueID, e.getKey());
        // block 從1開始計數
        int block = blockID(index + 1);
        List<String> sliceQueue = sliceQueue(queueID);
        String sliceID;
        if (block - 1 < sliceQueue.size()) {
            sliceID = sliceQueue.get(block - 1);
        } else {
            // create a new slice
            sliceID = String.valueOf(block);
            if (!sliceQueue.contains(sliceID)) {
                Preconditions.checkArgument(index <= size(queueID));
                jedis.rpush(makeSliceQueueKey(queueID), sliceID);
            } else {
                sliceID = sliceQueue.get(sliceQueue.size() - 1);
            }
        }
        String poolQueueKey = makePoolQueueKey(queueID, sliceID);
        Long length = jedis.llen(poolQueueKey);
        long offset = blockOffset(index);
        if (offset <= length) {
            offset = length - 1;
        }
        String position = jedis.lindex(makePoolQueueKey(queueID, sliceID), offset);
        if (isNil(position)) {
            jedis.rpush(poolQueueKey, e.getKey());
        } else {
            jedis.linsert(poolQueueKey, BinaryClient.LIST_POSITION.AFTER, position, e.getKey());
        }
        jedis.hset(makeDataKey(queueID), e.getKey(), JSONObject.toJSONString(e));
    } finally {
        unLockQueue(queueID);
    }
    return true;
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:43,代碼來源:JedisSegmentQueueStore.java


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