--- title: "Insert Data to Cache" url: https://docs.catalyst.zoho.com/en/sdk/python/v1/cloud-scale/cache/insert-data-into-cache/ description: "This page describes the method to insert data into the cache in your Python application with sample code snippets." last_updated: 2025-11-19T15:07:41Z service: Cloud Scale type: general related_links: - name: "Insert Data to Cache - API" url: /en/api/code-reference/cloud-scale/cache/insert-key-value-in-segment/#InsertKey-ValueinCacheSegment - name: "Cache Help" url: /en/cloud-scale/help/cache/introduction - name: "SDK Scopes" url: /en/sdk/python/v1/sdk-scopes --- # Insert Data in Cache You can insert a [cache element](https://docs.catalyst.zoho.com/en/cloud-scale/help/cache/introduction) using the put() method. This enables you to insert a key-value pair in an existing cache segment in your Catalyst project. The key name and key value are of type String and are passed as arguments to the method. You can also optionally pass the expiry time parameter. The expiration time will be set to 48 hours by default if the value is not specified explicitly. To know more about the [component instance](https://docs.catalyst.zoho.com/en/sdk/python/v1/cloud-scale/cache/get-component-instance/) `cache_service` and the [segment instance](en/sdk/python/v1/cloud-scale/cache/get-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 to be inserted in the cache.
`cache_value` String A **Mandatory** parameter. Will hold the value to be inserted in the cache.
`expiry_in_hours` Numeric A **Optional** parameter. Will hold the value of the expiry time of the data.
```python # Insert Data to Cache cache_service = app.cache() segment_service = cache_service.segment() segment_service.put('Name', 'Smith',2) ``` A sample response is shown below : ```json { cache_name: "Name", cache_value: "Smith", project_details: { project_name: "AlienCity", id: "2136000000007733" }, segment_details: { segment_name: "Location", id: "1234324234" }, expires_in: "Aug 18, 2021 06:46 PM", expiry_in_hours: "2", ttl_in_milliseconds: "172800000" } ``` > **Info :** Refer to the [SDK Scopes table](https://docs.catalyst.zoho.com/en/sdk/python/v1/sdk-scopes) to determine the required permission level for performing the above operation.