--- title: "Retrieve Data from the Cache" url: https://docs.catalyst.zoho.com/en/sdk/java/v1/cloud-scale/cache/retrieve-data-from-cache/ description: "This page describes the method to retrieve data from the cache in your Java application with sample code snippets." last_updated: 2025-11-19T15:07:41Z service: Cloud Scale type: general related_links: - name: "Retrieve Data from the Cache - API" url: /en/api/code-reference/cloud-scale/cache/get-cache-value/#GetCacheValue - name: "Cache" url: /en/cloud-scale/help/cache/introduction --- # Retrieve Data from Cache ### Retrieve the value by key name Every cache segment contains key-value pairs. Both keys and values are _String_ type. The value of a key is retrieved through the `getCacheValue()` method. #### Sample Code Snippet **Package Imports** ```java import com.zc.component.cache.ZCCache; import com.zc.component.cache.ZCSegment; ``` ```java //Get a Cache Instance ZCCache cacheobj=ZCCache.getInstance(); //Get an instance of a specific segment with segment ID ZCSegment segment = cacheobj.getSegment(1510000000054091L); //Get The value of the cache object using key String cacheValue= segment.getCacheValue("Val"); ``` ### Retrieve the cache object by key name Another variant for retrieving a cache object is to return the corresponding value of a key as a cache object. > **Note:** The cache object contains all of its attributes such as key, value, and expiry time. #### Sample Code Snippet **Package Imports** ```java import com.zc.component.cache.ZCCache; import com.zc.component.cache.ZCCacheObject; import com.zc.component.cache.ZCSegment; ``` ```java //Get a Cache Instance ZCCache cacheobj=ZCCache.getInstance(); //Get an instance of a specific segment with segment ID ZCSegment segment = cacheobj.getSegment(1510000000054091L); //replace segment id //Get The Cache object using key ZCCacheObject cacheValue = segment.getCacheObject("Name"); // replace cache key ```