Skip to content

Get Key Expiration Time

Description

This operation retrieves the expiration time for a key. The expiration time is expressed as a number of seconds until the key expires. Note that all keys are created without timeouts by default, and you can set it by invoking the "Set Key Expiration - TTL" or the "Set Key Expiration - Unix time" operations.

Method

Backendless.Hive(hiveName).[bucketType](keyName).getExpiration(): Promise<number>;

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
[bucketType] This placeholder must be substituted with one of the following stores: KeyValueStore, ListStore, MapStore, SetStore, SortedSetStore.
keyName Key name to get the timeout value for.

Return Value

The number of seconds until a specific key expires.

Example

The example below returns the number of seconds left until the expiration of the 'fruits' key.

await Backendless.Hive('groceryStore').ListStore('fruits').getExpiration()

where:

Argument                Description
'groceryStore' Name of a hive where the operation is performed.
'fruits' Key name in the store to check the expiration time.


Codeless Reference
general_api_get_key_expiration_time

where:

Argument                Description
hive name Name of a hive where the operation is performed.
type Storage type, can be one of the following: Key / Value, Sorted Set, Set, Map, List.
key name Key name to get the timeout value for.

Returns the number of seconds until a specific key expires.

Consider the following Key Value storage:

sample-key-value

The example below gets the timeout value for the "Japan" key:

general_api_example_get_key_expiration_time
The output will look as shown below after the Codeless logic runs.
general_api_example_get_key_expiration_time_2