当前位置: 首页>>代码示例>>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;未经允许,请勿转载。