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


Java Jedis.lindex方法代码示例

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


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

示例1: lindex

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public String lindex(String key) {
	Jedis jedis = null;
	boolean success = true;
	String ret = null;
	try {
		jedis = jedisPool.getResource();
		if (jedis == null) {
			success = false;
			return ret;
		}
		ret = jedis.lindex(key, 0);
	} catch (Exception e) {
		success = false;
		returnBrokenResource(jedis, "lpop key:" + key, e);
	} finally {
		releaseReidsSource(success, jedis);
	}
	return ret;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:RedisService.java

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

示例3: lindex

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public String lindex(String key, long index) {
    Jedis jedis = null;
    String res = null;
    try {
        jedis = pool.getResource();
        res = jedis.lindex(key, index);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
开发者ID:wxiaoqi,项目名称:ace-cache,代码行数:16,代码来源:RedisServiceImpl.java

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