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.shared hive:(NSString *)hiveName] storeType:(NSString *)keyName] getExpirationWithResponseHandler:^(NSInteger)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).storeType(keyName: String).getExpiration(responseHandler: ((Int) -> Void)!, errorHandler: ((Fault) -> Void)!)
where:
Argument | Description |
---|---|
hiveName |
Name of a hive where the operation is performed. String value. |
storeType |
This placeholder must be substituted with one of the following stores types: keyValueStore , listStore , mapStore , setStore , sortedSetStore . |
keyName |
Key name to get the timeout value for. String value. |
Return Value¶
The number of seconds until a specific key expires.
If the specified key does not exist, then the following Backendless error is returned:
{
"code": 27003,
"message": "no such key",
"errorData": {}
}
If the specified key has no timeouts set, then the following Backendless error is returned:
{
"code": 27010,
"message": "Expiration for key wasn't set.",
"errorData": {}
}
Example¶
The example below checks if a timeout is set on the "fruits"
key, and returns the number of seconds until expiration of the key.
[[[Backendless.shared hive:@"groceryStore"] listStore:@"fruits"] getExpirationWithResponseHandler:^(NSInteger response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").listStore("fruits").getExpiration(responseHandler: { response in
// handle response
}, errorHandler: { fault in
// handle error
})
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
¶
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:
The example below gets the timeout value for the "Japan"
key:
The output will look as shown below after the Codeless logic runs.