-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DATAREDIS-1151 - Provide an example of using scan as an option in RedisCache #547
Conversation
// | ||
// if (keys.length > 0) { | ||
// connection.del(keys); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a behavior change for you, maybe we could keep both and use a feature flag to toggle the choice?
|
||
if (keys.length > 0) { | ||
connection.del(keys); | ||
int batchSize = 1000; // maybe make it configurable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user choose to use SCAN
approach, we could let them configure this batch size as well, so that the Redis timeout
option and batch delete size
option are both in the hands of users.
if (keys.length > 0) { | ||
connection.del(keys); | ||
int batchSize = 1000; // maybe make it configurable | ||
ScanOptions options = ScanOptions.scanOptions().match(new String(pattern)).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batchSize here seems not applied to ScanOptions
keys[i] = cursor.next(); | ||
} | ||
|
||
connection.del(keys); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keys array may contains null element, which may fail DEL or UNLINK command.
Also, we can check if redis support UNLINK command.
private boolean isUnLinkSupported(RedisConnection redisConnection) {
if (unlinkSupported == null) {//private volatile Boolean unlinkSupported = null;
String smokingKey = "unlink-test" + System.currentTimeMillis() + UUID.randomUUID().toString();
try {
redisConnection.unlink(smokingKey.getBytes());
unlinkSupported = true;
} catch (RedisSystemException e) {
unlinkSupported = false;
}
}
return unlinkSupported;
}
Usage of |
I commented out the original implementation and added an example of using
SCAN
.After a second thought, it might be reasonable to keep both and allow users to toggle the choice?