Skip to content

Allow caching null objects. #1303

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

Merged
merged 1 commit into from
Jan 17, 2022
Merged

Conversation

mikereiche
Copy link
Collaborator

Use toStoreValue(value) to substitute null objects with NullValue.INSTANCE when putting. fromStoreValue(value) does the opposite when getting.

Closes #939.

  • You have read the Spring Data contribution guidelines.
  • There is a ticket in the bug tracker for the project in our JIRA.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@mikereiche mikereiche requested review from daschl and dnault January 15, 2022 18:56
Copy link
Contributor

@dnault dnault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with some nits.

/**
* This is a standalone class (vs. inner) to allow Serialization of all fields to work.
* If it was an inner class of CouchbaseCacheIntegrationTests, then it would have a
* this$0 field = CouchbaseCacheIntegrationTests and would not serialize.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CacheUser were a static nested class, would it it still need to be in a separate file?

https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

Copy link
Contributor

@dnault dnault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with some nits.

* @author Michael Reiche
*/
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
class CouchbaseCacheIntegrationTests extends JavaIntegrationTests {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are good. Are they related to the "Allow caching null objects" change?

Should we have a test that caches and retrieves a null value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cacheHitMiss() tests a cache hit on a stored null.
It also tests a cache-miss - which is the same for a null as a non-null.
The other tests have cache-hits on non-null (the normal case).

@mikereiche mikereiche merged commit 317d9b8 into main Jan 17, 2022
mikereiche added a commit that referenced this pull request Feb 4, 2022
Closes #939.

Co-authored-by: mikereiche <[email protected]>
mikereiche added a commit that referenced this pull request Feb 8, 2022
Closes #939.

Co-authored-by: mikereiche <[email protected]>
@mikereiche mikereiche deleted the datacouch_939_allow_caching_null branch April 11, 2022 20:52
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.

cache.put("key",null) fails [DATACOUCH-628]
2 participants