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

Optionally do not throw exception from Touch command when record does not exist #137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

volgunin-ttd
Copy link

Add failOnTouchRecordDoesNotExist parameter to WritePolicy to optionally not throw an exception when touching records that do not exist.

Remove exception-handling overhead associated with touching expired records in high-volume applications.

Default value is true to keep compatibility with existing behavior.

@rbotzer
Copy link
Member

rbotzer commented Oct 29, 2024

@volgunin-ttd we're going to discuss this PR internally. Unless I'm wrong, it's not idiomatic in C# or Java to return error codes instead of raising an exception. That said, get() returns null rather than raise an exception if there's no record, and exists() explicitly returns true|false, rather than raise an exception. This may be better addressed by a separate method that returns true|false to indicate whether the record was touched or not, based on whether it existed or not.

@volgunin-ttd
Copy link
Author

volgunin-ttd commented Oct 31, 2024

@rbotzer the change does not involve returning an error code instead of throwing an exception, the Touch method signature does not change. It is about not throwing an exception when the application does not need to know whether the existing record was touched or not and does not want to have exception-handling overhead.

I am following the existing pattern that already exist in Touch and Put commands that do not have return values and do not throw an exception when ResultCode is FILTERED_OUT and writePolicy.failOnFilteredOut is false.

The proposed change does not change method signatures and does not modify behavior of existing code, but allows performance-based optimization for those who want it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants