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


Java Jedis.rpush方法代码示例

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


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

示例1: addBatch

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public void addBatch(String queueID, Set<ResourceItem> resourceItems) {
    if (!lockQueue(queueID)) {
        return;
    }
    final Jedis jedis = jedisPool.getResource();
    final String dataKey = makeDataKey(queueID);
    try {
        final Set<String> hkeys = jedis.hkeys(dataKey);
        Set<ResourceItem> filterSet = Sets.filter(resourceItems, new Predicate<ResourceItem>() {
            @Override
            public boolean apply(ResourceItem input) {
                return !hkeys.contains(input.getKey());
            }
        });

        String poolQueueKey = makePoolQueueKey(queueID);
        for (ResourceItem resourceItem : filterSet) {
            jedis.hset(dataKey, resourceItem.getKey(), JSONObject.toJSONString(resourceItem));
            jedis.rpush(poolQueueKey, resourceItem.getKey());
        }
    } finally {
        IOUtils.closeQuietly(jedis);
        unLockQueue(queueID);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:27,代码来源:JedisQueueStore.java

示例2: setList

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 设置List缓存
 *
 * @param key          键
 * @param value        值
 * @param cacheSeconds 超时时间,0为不超时
 * @return
 */
public static long setList(String key, List<String> value, int cacheSeconds) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			jedis.del(key);
		}
		result = jedis.rpush(key, (String[]) value.toArray());
		if (cacheSeconds != 0) {
			jedis.expire(key, cacheSeconds);
		}
		logger.debug("setList {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
开发者ID:funtl,项目名称:framework,代码行数:29,代码来源:JedisUtils.java

示例3: setObjectList

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 设置List缓存
 *
 * @param key          键
 * @param value        值
 * @param cacheSeconds 超时时间,0为不超时
 * @return
 */
public static long setObjectList(String key, List<Object> value, int cacheSeconds) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(getBytesKey(key))) {
			jedis.del(key);
		}
		List<byte[]> list = Lists.newArrayList();
		for (Object o : value) {
			list.add(toBytes(o));
		}
		result = jedis.rpush(getBytesKey(key), (byte[][]) list.toArray());
		if (cacheSeconds != 0) {
			jedis.expire(key, cacheSeconds);
		}
		logger.debug("setObjectList {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setObjectList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
开发者ID:funtl,项目名称:framework,代码行数:33,代码来源:JedisUtils.java

示例4: listObjectAdd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 向List缓存中添加值
 *
 * @param key   键
 * @param value 值
 * @return
 */
public static long listObjectAdd(String key, Object... value) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		List<byte[]> list = Lists.newArrayList();
		for (Object o : value) {
			list.add(toBytes(o));
		}
		result = jedis.rpush(getBytesKey(key), (byte[][]) list.toArray());
		logger.debug("listObjectAdd {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("listObjectAdd {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
开发者ID:funtl,项目名称:framework,代码行数:26,代码来源:JedisUtils.java

示例5: rPushString

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/** 返回的是列表的剩余个数 */
public long rPushString(String key, String value) {
	Jedis jedis = null;
	boolean success = true;
	long ret = 0;
	try {
		jedis = jedisPool.getResource();
		if (jedis == null) {
			success = false;
			return ret;
		}
		ret = jedis.rpush(key, value);
	} catch (Exception e) {
		success = false;
		returnBrokenResource(jedis, "rpushString" + key, e);
	} finally {
		releaseReidsSource(success, jedis);
	}
	return ret;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:21,代码来源:RedisService.java

示例6: rpush

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

示例7: setVByList

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 往redis里存List
 * @param listKey
 * @param value
 */
public void setVByList(String listKey,Object value) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		byte[] svalue = SerializeUtil.serialize(value);
		jds.rpush(listKey.getBytes(), svalue);
	} catch (Exception e) {
		throw e;
	} finally {
		if(jds != null)
		{
			jds.close();
		}
	}
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:22,代码来源:RedisManager.java

示例8: setList

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 设置List缓存
 * @param key 键
 * @param value 值
 * @param cacheSeconds 超时时间,0为不超时
 * @return
 */
public static long setList(String key, List<String> value, int cacheSeconds) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			jedis.del(key);
		}
		result = jedis.rpush(key, (String[])value.toArray());
		if (cacheSeconds != 0) {
			jedis.expire(key, cacheSeconds);
		}
		logger.debug("setList {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:28,代码来源:JedisUtils.java

示例9: main

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    Bench<JedisPool> bench = new JedisBench() {
        @Override
        public void executeOperation(String data, JedisPool benchInstance, int threadNumber, int iteration,
                MetricRegistry metrics) {
            Jedis jedis = benchInstance.getResource();

            Timer.Context time = metrics.timer("list").time();
            String key = "list_" + threadNumber;
            jedis.rpush(key, data);
            time.stop();

            jedis.close();
        }
    };
    
    Benchmark benchmark = new Benchmark(bench);
    benchmark.run(args);
}
 
开发者ID:redisson,项目名称:redisson-benchmark,代码行数:20,代码来源:ListAddBenchmark.java

示例10: push

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public void push(Request request, ISpider spider) {
       Jedis jedis = pool.getResource();
       if (Const.HttpMethod.POST == request.getMethod()
			|| !isDuplicate(request, spider)) {
		log.debug("push to queue {}", request.getUrl());
		 try {
	            jedis.rpush(getQueueKey(spider), request.getUrl());
	            String field = DigestUtils.md5Hex(request.getUrl());
	            byte[] data=SerializationUtils.serialize(request);
	            jedis.hset((ITEM_PREFIX + spider.getName()).getBytes(), field.getBytes(), data);
			} finally {
	            jedis.close();
	        }
	}
   }
 
开发者ID:xbynet,项目名称:crawler,代码行数:17,代码来源:RedisScheduler.java

示例11: addLast

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public boolean addLast(String queueID, ResourceItem e) {
    if (!lockQueue(queueID)) {
        return false;
    }
    remove(queueID, e.getKey());
    Jedis jedis = jedisPool.getResource();
    try {
        jedis.rpush(makePoolQueueKey(queueID), e.getKey());
        jedis.hset(makeDataKey(queueID), e.getKey(), JSONObject.toJSONString(e));
    } finally {
        IOUtils.closeQuietly(jedis);
        unLockQueue(queueID);
    }
    return true;
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:17,代码来源:JedisQueueStore.java

示例12: setSetObjectAdd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 向Set缓存中添加值
 * @param key 键
 * @param value 值
 * @return
 */
public static long setSetObjectAdd(String key, Object... value) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		Set<byte[]> set = Sets.newHashSet();
		for (Object o : value){
			set.add(toBytes(o));
		}
		result = jedis.rpush(getBytesKey(key), (byte[][])set.toArray());
		logger.debug("setSetObjectAdd {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setSetObjectAdd {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:25,代码来源:JedisUtils.java

示例13: addBatch

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public void addBatch(String queueID, Set<ResourceItem> resourceItems) {
    if (!lockQueue(queueID)) {
        return;
    }
    @Cleanup Jedis jedis = jedisPool.getResource();
    final String dataKey = makeDataKey(queueID);
    try {
        final Set<String> hkeys = jedis.hkeys(dataKey);
        Set<ResourceItem> filterSet = Sets.filter(resourceItems, new Predicate<ResourceItem>() {
            @Override
            public boolean apply(ResourceItem input) {
                return !hkeys.contains(input.getKey());
            }
        });
        List<String> sliceQueue = sliceQueue(queueID);
        Set<String> newSlices = Sets.newHashSet();
        long index = size(queueID) + 1;
        String tailSlice = null;
        for (ResourceItem resourceItem : filterSet) {
            jedis.hset(dataKey, resourceItem.getKey(), JSONObject.toJSONString(resourceItem));
            String sliceID = String.valueOf(blockID(index));
            if (sliceID.equals(tailSlice) || sliceQueue.contains(sliceID)) {
                sliceID = sliceQueue.get(sliceQueue.size() - 1);
                tailSlice = sliceID;
            } else if (!newSlices.contains(sliceID)) {
                jedis.rpush(makeSliceQueueKey(queueID), sliceID);
                newSlices.add(sliceID);
            }
            jedis.rpush(makePoolQueueKey(queueID, sliceID), resourceItem.getKey());
            index++;
        }
    } finally {
        unLockQueue(queueID);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:37,代码来源:JedisSegmentQueueStore.java

示例14: listAdd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 向List缓存中添加值
 *
 * @param key   键
 * @param value 值
 * @return
 */
public static long listAdd(String key, String... value) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		result = jedis.rpush(key, value);
		logger.debug("listAdd {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("listAdd {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
开发者ID:funtl,项目名称:framework,代码行数:22,代码来源:JedisUtils.java

示例15: pushWhenNoDuplicate

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
protected void pushWhenNoDuplicate(Request request) {

    Jedis jedis = pool.getResource();
    try {
        jedis.rpush(getQueueKey(request.getSpiderName()), request.getUrl());
        String field = DigestUtils.shaHex(request.getUrl());
        String value = JSON.toJSONString(request);
        jedis.hset((ITEM_PREFIX + request.getUrl()), field, value);
    } finally {
        jedis.close();
    }

}
 
开发者ID:fengzhizi715,项目名称:NetDiscovery,代码行数:15,代码来源:RedisQueue.java


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