Skip to content

Extending the life of object in cache

There are two way to extend object's life in cache - relative timeframe and fixed timeframe. With the relative timeframe a period of time is added to the timestamp of the call to determine the new expiration time. The fixed timestamp approach sets the timestamp when the object must expire from cache.

Method:

PUT

Endpoint URL

The xxxx.backendless.app is a subdomain assigned to your application. For more information see the Client-side Setup section of this documentation.

Relative extension:

https://xxxx.backendless.app/api/cache/<key>/expireIn?timeout=<seconds>

Fixed timestamp:

https://xxxx.backendless.app/api/cache/<key>/expireAt?timestamp=<timestamp>

where:

Argument                Description
<key> Identifies the object to extend the life of in cache.
<seconds> Number of seconds to extend the life of object in cache by. Must be a value between 1 and 7200 (2 hours).
<timestamp> A timestamp in milliseconds when the object should expire and removed from cache. The difference between timestamp and the current time must be greater than zero, equal or less than 7200000 milliseconds (2 hours).

Request headers

Content-Type: application/json  
user-token: optional value obtained as a result of the login operation.

where:

Argument                Description
Content-Type Must be set to application/json. This header is mandatory.
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is set in the request, the currently logged in user will be assigned to the ownerId property of the user object which is being saved.  Additionally, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and the roles assigned to the user will be enforced by Backendless.

Request body

N/A

Example

Make sure to replace xxxx in the domain name in the sample request below to the one assigned to your application.

Relative time extension:

curl -X PUT \  
https://xxxx.backendless.app/api/cache/myorder/expireIn?timeout=1200

Absolute time extension:

curl -X PUT \  
[`https://xxxx.backendless.app/api/cache/myorder/expireAt?timestamp=1407213507898`](https://xxxx.backendless.app/api/cache/myorder/expireAt?timestamp=1407213507898)

Codeless Reference

caching_codeless_extending_object_life_1

where:

Argument                Description
key name Key assigned to the object to identify it in cache. The key is used to extend the life of an object in the cache.
in seconds Number of seconds to extend the life of an object in cache by. Must be a value between 1 and 7200 (2 hours).

This operation does not return a value.

Consider the expiration time(expireAt column) of the following key-value pair stored in cache:

caching_codeless_putting_data_into_cache_3

The example below extends the life of the object associated with the "orderName" key by 7200 seconds(2 hours)

caching_codeless_extending_object_life_2

The operation has successfully extended the life of the object. The value in the expireAt column indicates the corresponding change (before: 04/10/2023 16:57:23) -> (after: 04/10/2023 18:10:35)

caching_codeless_extending_object_life_3