當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。