Introduction and Example of Zend Data Cache

As we have already explained the Zend Data Cache in Cache Introduction.
Zend data comes in action when it is imprectical or impossible to cache entire page output. For example if your section of data are more dynamic in nature like you are trying to cache your payment form where you have your credit card numbers, customer’s address and production info and so on in that case its not a better idea to cache output of full page instead of that Zend Data cache can be one good option here.

Following are the functionalities that can be achieved using data cache
*. Storing variables to the cache
*. Fetching variables to the cache
*. Deleting variables from the cache
*. Clearing the cache
*. Disk/Memory (SHM) storage
*. Caching using namespaces
*. Cache folder depth configuration

There are two functions that are used to achieve Zend data cache. These functions are

i) zend_shm_cache_store() : This function is used to store data into shared memory cache.
ii) zend_shm_cache_fetch() : This function is used to fetch data from shared memory.
iii) zend_disk_cache_store: To store cache in disk
iv) zend_disk_cache_fetch: To fetch cache from disk

Here one thing is notable that Zend offers two types of storage modules.
a) The Shared Modules (“shm”)
b) Disk Modules

if (zend_disk_cache_store("test1", 1) === false){
echo "Error in storing data";    exit();
}
if (zend_disk_cache_fetch("test1") === false){
echo "Error in fetching data";    exit();
}

Hope you have enjoyed..

Related posts:

The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video... Read More about Chandra Shekhar

Latest posts by Chandra Shekhar (see all)