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.
To know more about the component instance cache_service and the segment_service segment_service used below, please refer to their respective help sections.
Parameters Used
Parameter Name | Data Type | Definition |
---|---|---|
Key | String | A Mandatory parameter. Will hold the key for retrieving the cache value. |
copy#Get cache value cache_service = app.cache() segment_service = cache_service.segment() 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.
To know more about the component instance cache_service and the segment instance segment_service used below, please refer to their respective help sections.
Parameters Used
Parameter Name | Data Type | Definition |
---|---|---|
cache_name | String | A Mandatory parameter. Will hold the key for retrieving the cache object. |
copycache_service = app.cache() segment_service = cache_service.segment() data = 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 2025-03-28 18:24:49 +0530 +0530
Yes
No
Send your feedback to us