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

FEAT / Added config to disable attempt to update before insert in cache #1787

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public void create() {
// CouchbaseEntryManagerFactory.PERSISTENCE_TYPE
skipRemoveBeforePut = "couchbase".equals(persistenceType);
attemptUpdateBeforeInsert = "sql".equals(persistenceType);
if (cacheConfiguration.getNativePersistenceConfiguration().isDisableAttemptUpdateBeforeInsert()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we don't need explicit configuration for it. Existing attemptUpdateBeforeInsert = "sql".equals(persistenceType); is enough. With this we already updating entry (for all further calls except initial one).

@yurem is it what you meant in #207 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I talked with him before doing these changes, but let's see Yure's feedback in case I misunderstood something.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, for #207 we already updated code. But this new property will allow us to check at runtime which approach is better for specific DB MySQL/Postgress/etc

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, yes, it can be useful.

attemptUpdateBeforeInsert = false;
}

log.info("Created NATIVE_PERSISTENCE cache provider. `baseDn`: " + baseDn);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class NativePersistenceConfiguration implements Serializable {
@XmlElement(name = "deleteExpiredOnGetRequest")
private boolean deleteExpiredOnGetRequest = false;

@XmlElement(name = "disableAttemptUpdateBeforeInsert")
private boolean disableAttemptUpdateBeforeInsert = false;

@JsonIgnore
private String baseDn;

Expand Down Expand Up @@ -53,7 +56,15 @@ public void setDeleteExpiredOnGetRequest(boolean deleteExpiredOnGetRequest) {
this.deleteExpiredOnGetRequest = deleteExpiredOnGetRequest;
}

public String getBaseDn() {
public boolean isDisableAttemptUpdateBeforeInsert() {
return disableAttemptUpdateBeforeInsert;
}

public void setDisableAttemptUpdateBeforeInsert(boolean disableAttemptUpdateBeforeInsert) {
this.disableAttemptUpdateBeforeInsert = disableAttemptUpdateBeforeInsert;
}

public String getBaseDn() {
return baseDn;
}

Expand All @@ -64,6 +75,8 @@ public void setBaseDn(String baseDn) {
@Override
public String toString() {
return "NativePersistenceConfiguration [defaultPutExpiration=" + defaultPutExpiration + ", defaultCleanupBatchSize="
+ defaultCleanupBatchSize + ", deleteExpiredOnGetRequest=" + deleteExpiredOnGetRequest + ", baseDn=" + baseDn + "]";
+ defaultCleanupBatchSize + ", deleteExpiredOnGetRequest=" + deleteExpiredOnGetRequest
+ ", disableAttemptUpdateBeforeInsert=" + disableAttemptUpdateBeforeInsert
+ ", baseDn=" + baseDn + "]";
}
}