The Increment() methods increase the value of a
given key if the corresponding value can be parsed to an integer
value. These operations are provided at a protocol level to
eliminate the need to get, update, and reset a simple integer
value in the database. All the .NET Client Library methods support
the use of an explicit offset value that will be used to reduce
the stored value in the database.
| API Call | object.Increment(key, defaultvalue, offset) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | CasResult<ulong> (
Cas result of bool
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
Increment the inventory counter by 1, defaulting to 100 if the key doesn't exist.
client.Increment("inventory", 100, 1);| API Call | object.Increment(key, defaultvalue, offset, validfor) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | CasResult<ulong> (
Cas result of bool
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
TimeSpan validfor | Expiry time (in seconds) for key | ||
Increment the inventory counter by 1, defaulting to 100 if the key doesn't exist and set an expiry of 60 seconds.
client.Increment("inventory", 100, 1, TimeSpan.FromSeconds(60));| API Call | object.Increment(key, defaultvalue, offset, expiresat) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | CasResult<ulong> (
Cas result of bool
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
DateTime expiresat | Explicit expiry time for key | ||
Increment the inventory counter by 1, defaulting to 100 if the key doesn't exist and set an expiry of 5 minutes.
client.Increment("inventory", 100, 1, DateTime.Now.AddMinutes(5));| API Call | object.Increment(key, defaultvalue, offset, casunique) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | CasResult<ulong> (
Cas result of bool
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
ulong casunique | Unique value used to verify a key/value combination | ||
Increment the inventory counter by 1, defaulting to 100 if the key doesn't exist.
var casv = client.GetWithCas("inventory"); client.Increment("inventory", 100, 1, cas.Cas);
| API Call | object.Increment(key, defaultvalue, offset, validfor, casunique) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | CasResult<ulong> (
Cas result of bool
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
TimeSpan validfor | Expiry time (in seconds) for key | ||
ulong casunique | Unique value used to verify a key/value combination | ||
Increment the inventory counter by 1, defaulting to 100 if the key doesn't exist and set an expiry of 60 seconds.
var casv = client.GetWithCas("inventory"); client.Increment("inventory", 100, 1, TimeSpan.FromSeconds(60), cas.Cas);
| API Call | object.Increment(key, defaultvalue, offset, expiresat, casunique) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | CasResult<ulong> (
Cas result of bool
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
DateTime expiresat | Explicit expiry time for key | ||
ulong casunique | Unique value used to verify a key/value combination | ||
Increment the inventory counter by 1, defaulting to 100 if the key doesn't exist and set an expiry of 5 minutes.
var casv = client.GetWithCas("inventory"); client.Increment("inventory", 100, 1, DateTime.Now.AddMinutes(5), cas.Cas);
| API Call | object.ExecuteIncrement(key, defaultvalue, offset) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | IMutateOperationResult (
Mutate operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
Increment the inventory counter by 1, defaulting to 100 if the key
doesn't exist. Return an instance of an
IMutateOperationResult.
var result = client.Increment("inventory", 100, 1); if (result.Success) { logger.Debug("New value: " + result.Value); }
| API Call | object.ExecuteIncrement(key, defaultvalue, offset, validfor) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | IMutateOperationResult (
Mutate operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
TimeSpan validfor | Expiry time (in seconds) for key | ||
Increment the inventory counter by 1, defaulting to 100 if the key
doesn't exist and set an expiry of 60 seconds. Return an instance
of an IMutateOperationResult.
var result = client.Increment("inventory", 100, 1); if (result.Success) { logger.Debug("New value: " + result.Value); }
| API Call | object.ExecuteIncrement(key, defaultvalue, offset, expiresat) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | IMutateOperationResult (
Mutate operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
DateTime expiresat | Explicit expiry time for key | ||
Increment the inventory counter by 1, defaulting to 100 if the key
doesn't exist and set an expiry of 5 minutes. Return an instance
of an IMutateOperationResult.
client.ExecuteIncrement("inventory", 100, 1, DateTime.Now.AddMinutes(5));| API Call | object.ExecuteIncrement(key, defaultvalue, offset, casunique) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | IMutateOperationResult (
Mutate operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
ulong casunique | Unique value used to verify a key/value combination | ||
Increment the inventory counter by 1 using check and set,
defaulting to 100 if the key doesn't exist. Return an instance of
an IMutateOperationResult.
var getResult = client.ExecuteGet("inventory"); if (getResult.Success) { var mutateResult client.ExecuteIncrement("inventory", 100, 1, getResult.Cas); if (mutateResult.Success) { logger.Debug("New value: " + mutateResult.Value); } }
| API Call | object.ExecuteIncrement(key, defaultvalue, offset, validfor, casunique) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | IMutateOperationResult (
Mutate operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
TimeSpan validfor | Expiry time (in seconds) for key | ||
ulong casunique | Unique value used to verify a key/value combination | ||
ExecuteIncrement the inventory counter by 1 using check and set,
defaulting to 100 if the key doesn't exist and set an expiry of 60
seconds. Return an instance of an
IMutateOperationResult.
var getResult = client.ExecuteGet("inventory"); var mutateResult = client.ExecuteIncrement("inventory", 100, 1, TimeSpan.FromSeconds(60), getResult.Cas);
| API Call | object.ExecuteIncrement(key, defaultvalue, offset, expiresat, casunique) | ||
| Asynchronous | no | ||
| Description | Increment the value of an existing numeric key. Couchbase Server stores numbers as unsigned numbers, therefore if you try to increment an existing negative number, it will cause an integer overflow and return a non-logical numeric result. If a key does not exist, this method will initialize it with the zero or a specified value. | ||
| Returns | IMutateOperationResult (
Mutate operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
object defaultvalue | Value to be stored if key does not already exist | ||
Integer offset | Integer offset value to increment/decrement (default 1) | ||
DateTime expiresat | Explicit expiry time for key | ||
ulong casunique | Unique value used to verify a key/value combination | ||
Increment the inventory counter by 1 using check and set,
defaulting to 100 if the key doesn't exist and set an expiry of 5
minutes. Return an instance of an
IMutateOperationResult.
var getResult = client.ExecuteGet("inventory"); var mutateResult = client.ExecuteIncrement("inventory", 100, 1, DateTime.Now.AddMinutes(5), getResult.Cas);