I am trying to name a method which will only perform an update on a relational data store if the input data is new, meaning there is no existing key or the value differs from the previous. The motivation, is to not trigger a data change event which gets thrown by a standard update.

What is the correct terminology for such an update and what would an example signature be?

有帮助吗?

解决方案

So let's clarify your statement "only perform an update ... if the input data is new".

If you only focus on relational keys, updating only when keys change, then you don't really "only perform ... if ... new", as the values for the key might have changed.

However, if you really might have the exact same value applied twice, and you do nothing the second time, the system is idempotent. Idempotent apis assure a state after they are called, which will not alter in a replay situation.

A quick example of a non-idempotent call (due to API design)

incrementCount();

while an example of an idempotent call (with an API permitting it)

setCount(5);

Note that not doing anything isn't a feature of the idempotent api, but rather an optimization which is safe to perform for idempotent calls. Basically, with an idempotent api, you can do the following

if (currentCommand.equals(lastCommand)) {
  return;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top