Delete a key-value pair

When a key-value pair is no longer needed, it can be permanently deleted from the cache segment. The key-value pair cannot be restored once it is deleted,but it can be recreated.

Delete using a key

You can delete a key by passing it directly to the deleteCacheValue() method as a parameter.

Ensure the following packages are imported:

    
copy
import com.zc.component.cache.ZCCache; import com.zc.component.cache.ZCSegment;
    
copy
//Get a Cache Instance ZCCache cacheobj=ZCCache.getInstance(); //Get an instance of a specific segment with segment ID ZCSegment segment = cacheobj.getSegment(1510000000054091L); //Delete the Cache object using key segment.deleteCacheValue("Name");

Delete using a cache object

In this delete variant, an empty cache instance is constructed and the key value is set to it. This instance is passed as an argument to the deleteCacheObject() method.

Ensure the following packages are imported:

    
copy
import com.zc.component.cache.ZCCache; import com.zc.component.cache.ZCCacheObject; import com.zc.component.cache.ZCSegment;
    
copy
//Get a Cache Instance ZCCache cacheobj=ZCCache.getInstance(); //Get an instance of a specific segment with segment ID ZCSegment segment = cacheobj.getSegment(1510000000054091L); //Create a CacheObject and set cache details ZCCacheObject cacheDetails = ZCCacheObject.getInstance(); cacheDetails.setKeyName("ObjectKey"); //Delete the cache using the CacheObject segment.deleteCacheObject(cacheDetails);

Last Updated 2023-09-03 01:06:41 +0530 +0530