Skip to content

Commit 781c80d

Browse files
committed
add new constructor to redisscheduler
1 parent 4c57985 commit 781c80d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

webmagic-extension/src/main/java/us/codecraft/webmagic/scheduler/RedisScheduler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public RedisScheduler(String host) {
2929
pool = new JedisPool(new JedisPoolConfig(), host);
3030
}
3131

32+
public RedisScheduler(JedisPool pool) {
33+
this.pool = pool;
34+
}
35+
3236
@Override
3337
public synchronized void push(Request request, Task task) {
3438
Jedis jedis = pool.getResource();
@@ -59,7 +63,7 @@ public synchronized Request poll(Task task) {
5963
}
6064
String key = ITEM_PREFIX + task.getUUID();
6165
String field = DigestUtils.shaHex(url);
62-
byte[] bytes = jedis.hget(key.getBytes(),field.getBytes());
66+
byte[] bytes = jedis.hget(key.getBytes(), field.getBytes());
6367
if (bytes != null) {
6468
Request o = JSON.parseObject(new String(bytes), Request.class);
6569
return o;

0 commit comments

Comments
 (0)