Key-Value State Operations

The State provider has key-value operations for storing state.

Set a Value

Using a key, you can store a value for retrieval later.

Method Signature

Setting a Value

Increment a Value

If you have stored an integer you can increment it by a specified amount.

Method Signature

Incrementing a Value

Decrement a Value

If you have stored an integer you can decrement it by a specified amount.

Method Signature

Decrementing a Value

Get a Value

Using a key, you can fetch a value previously stored.

Method Signature

Getting a Value

Expire a Value

Using a key, you can expire a value previously stored after a specified number of seconds.

Method Signature

Types

expire supports a set of options(EXPIRE_OPTION):

  • NX: Set expiry only when the key has no expiry
  • XX: Set expiry only when the key has an existing expiry
  • GT: Set expiry only when the new expiry is greater than the current one
  • LT: Set expiry only when the new expiry is less than the current one

Expiring a Value

Delete a Value

Using a key, you can delete a value previously stored.

Method Signature

Deleting a Value