Retrieve data from the cache
Get Cache Value
Catalyst Cloud Scale Cache is divided into partitions or cache units called segments. Each segment stores cache items in the form of key-value pairs. Both keys and values are of type String.
You can retrieve the value of a cache item from a segment in the cache using the get_value() method. You must pass the key name as the argument and the value corresponding to that key will be returned as a response.
The segment_service reference used below is already defined in the component instance page.
copy#Get cache value data = segment_service.get_value('key')
A sample response is shown below :
copy{ "cache_name": "Name", "cache_value": "Amelia Burrows", "expires_in": "Mar 09, 2023 06:20 PM", "expiry_in_hours": "48", "project_details": { "id": "2648000001343001", "project_name": "appEngine", "project_type": "Live" }, "segment_details": { "id": "2648000001343037", "segment_name": "Default" }, "ttl_in_milliseconds": "172800000" }
Get Cache Object
You can retrieve the details of the cache where the key-value pair is of type dictionary. The key object is retrieved using the get() method, where the key name is passed as an argument.
The segment_service reference used below is already defined in the component instance page.
copydata = segment_service.get('key')
A sample response is shown below :
copy{ cache_name: "Name", cache_value: "Amelia Burrows", project_details: { project_name: "AlienCity", id: "2136000000007733" }, segment_details: { segment_name: "Location", id: "2136000000008572" }, expires_in: "Aug 18, 2021 06:39 PM", expiry_in_hours: "47", ttl_in_milliseconds: "172727000" }
Last Updated 2023-12-18 16:20:08 +0530 +0530
Yes
No
Send your feedback to us