--- title: "Insert Data in Cache" url: https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/cache/insert-data/ description: "This page describes the method to perform operations in the Cache component." last_updated: 2026-09-09T10:45:38Z service: CloudScale type: general related_links: - name: "Catalyst CloudScale" url: /en/cloud-scale/ - name: "Cache Help Documentation" url: /en/cloud-scale/help/cache/introduction/ - name: "Java SDK Documentation" url: /en/sdk/java/v1/cloud-scale/cache/insert-data-into-cache/ - name: "Python SDK Documentation" url: /en/sdk/python/v1/cloud-scale/cache/insert-data-into-cache/ - name: "REST API Documentation" url: /en/api/code-reference/cloud-scale/cache/insert-key-value-in-segment/#InsertKeyValueinCacheSegment repository: name: "Repository" url: https://github.com/catalystbyzoho/zcatalyst-sdk-js --- # Insert Data in Cache > **Note:** Ensure you have installed the [required package](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/cache/overview/#prerequisites) to use this SDK method. Using the `put()` SDK method, you can insert a cache item. You can insert a key-value pair in an existing cache segment in your Catalyst project. The key name and key value are of the **String** type and are passed as arguments to the method. The promise returned here will be resolved to a JSON object. You can also pass the *expiry time* for the cache item optionally. If you do not pass that value, the expiration time will be set to **48 hours** by default. The `segment` reference used in the code snippet below is the [segment instance](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/cache/get-segment-instance/). ```javascript //Insert Cache by passing the key-value pair const cache = new Cache(); const segment = cache.segment(); const entity = await segment.put('Name', 'Linda McCartney',1); //Expiry time for cache in hours console.log(entity); ``` #### Example of Expected Response ```json { "cache_name": "Last_Name", "cache_value": "Smith", "project_details": { "project_name": "AlienCity", "id": "2136000000007733" }, "segment_details": { "segment_name": "DataStore", "id": "2136000000008572" }, "expires_in": "Aug 18, 2021 06:46 PM", "expiry_in_hours": "48", "ttl_in_milliseconds": "172800000" } ```