Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

chengchen
Copy link

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?

//
// if (keys.length > 0) {
// connection.del(keys);
// }
Copy link
Author

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
Copy link
Author

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.

@chengchen chengchen changed the title Provide an example of using scan as an option DATAREDIS-1151 Provide an example of using scan as an option Jul 10, 2020
@mp911de mp911de changed the title DATAREDIS-1151 Provide an example of using scan as an option DATAREDIS-1151 - Provide an example of using scan as an option in RedisCache Oct 7, 2020
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 4, 2021
if (keys.length > 0) {
connection.del(keys);
int batchSize = 1000; // maybe make it configurable
ScanOptions options = ScanOptions.scanOptions().match(new String(pattern)).build();
Copy link

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);
Copy link

@rickgong rickgong Apr 8, 2021

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;
}

@gregturn gregturn changed the base branch from master to main April 16, 2021 17:46
@mp911de mp911de added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 21, 2021
@christophstrobl
Copy link
Member

Usage of SCAN command is now possible via aBatchStrategy. Resolved via #2051.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants