Change ScanResult's cursor type to byte[]
* It's less probabilities to conversion with byte[] <-> ?
This commit is contained in:
@@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
import redis.clients.util.SafeEncoder;
|
import redis.clients.util.SafeEncoder;
|
||||||
|
|
||||||
public class ScanResult<T> {
|
public class ScanResult<T> {
|
||||||
private String cursor;
|
private byte[] cursor;
|
||||||
private List<T> results;
|
private List<T> results;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -15,16 +15,14 @@ public class ScanResult<T> {
|
|||||||
* @see https://github.com/xetorthio/jedis/issues/531
|
* @see https://github.com/xetorthio/jedis/issues/531
|
||||||
*/
|
*/
|
||||||
public ScanResult(int cursor, List<T> results) {
|
public ScanResult(int cursor, List<T> results) {
|
||||||
this.cursor = String.valueOf(cursor);
|
this(Protocol.toByteArray(cursor), results);
|
||||||
this.results = results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScanResult(byte[] cursor, List<T> results) {
|
|
||||||
this.cursor = SafeEncoder.encode(cursor);
|
|
||||||
this.results = results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScanResult(String cursor, List<T> results) {
|
public ScanResult(String cursor, List<T> results) {
|
||||||
|
this(SafeEncoder.encode(cursor), results);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScanResult(byte[] cursor, List<T> results) {
|
||||||
this.cursor = cursor;
|
this.cursor = cursor;
|
||||||
this.results = results;
|
this.results = results;
|
||||||
}
|
}
|
||||||
@@ -37,18 +35,18 @@ public class ScanResult<T> {
|
|||||||
* @return int(currently), but will be changed to String, so be careful to prepare!
|
* @return int(currently), but will be changed to String, so be careful to prepare!
|
||||||
*/
|
*/
|
||||||
public int getCursor() {
|
public int getCursor() {
|
||||||
return Integer.parseInt(cursor);
|
return Integer.parseInt(getStringCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME: This method should be changed to getCursor() on next major release
|
* FIXME: This method should be changed to getCursor() on next major release
|
||||||
*/
|
*/
|
||||||
public String getStringCursor() {
|
public String getStringCursor() {
|
||||||
return cursor;
|
return SafeEncoder.encode(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBinaryCursor() {
|
public byte[] getBinaryCursor() {
|
||||||
return SafeEncoder.encode(cursor);
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<T> getResult() {
|
public List<T> getResult() {
|
||||||
|
|||||||
Reference in New Issue
Block a user