Last updated on
Apr 27, 2021
Description
This function enables or disables Time to Live (TTL) for a specified table.
For more information, see UpdateTimeToLive.
Category
History
ColdFusion (2021 release): Added this function.
Syntax
serviceHandle.updateTimeToLive(requestParameters)
Parameters
See the request parameters of UpdateTimeToLive.
Example
<cfscript>
cred = {
"credentialAlias" : "myalias",
"vendorName" : "AWS",
"region" : "us-east-2",
"secretAccessKey" : "xxxxx",
"accessKeyId" : "xxxx"
}
config = {
"serviceName" = "DYNAMODB"
}
dynamo = getCloudService(cred, config)
tableName="SessionData"
expirationLocalDate = DateAdd("s", "30", now());
utcExpirationdate = dateConvert("local2utc", expirationLocalDate)
expirationEpochTime = utcExpirationdate.getTime()
structPutItem = {
"TableName": "#tableName#",
"Item":{
"username": "user",
"sessionid": "00012345",
"expirationTime": "#expirationEpochTime#"
},
"ReturnValues": "ALL_OLD"
}
dynamo.putItem(structPutItem)
updateTimeToLiveStruct={
"TableName": "#tableName#",
"TimeToLiveSpecification": {
"AttributeName": "expirationTime",
"Enabled": TRUE
}
}
updateTimeToLiveResponse=dynamo.updateTimeToLive(updateTimeToLiveStruct)
writeDump(updateTimeToLiveResponse)
</cfscript>
Output