INC / DEC

Increments or decrements a number, and returns the new value. If the key doesn't exist, it is set to 0 before executing the operation.

  • INC: Add the given number to the value indexed by the given key.
  • DEC: Substract the given number from the value indexed by the given key.

These operations shouldn't be done on keys created by PUT/ADD.

Request

--------------------------------------------
| request | key length | key     | number  |
--------------------------------------------
  1 byte    2 bytes      n bytes   4 bytes

Response

--------------------
| answer | value   |
--------------------
  1 byte   4 bytes

Sync/async

INC and DEC requests are always synchronous (FineDB handle them using transactions).