As Opencart provides the cache library (cache.php), so here we will learn how to perform caching in Opencart. Opencart uses file cache by default and it provides files for performing 3 types of caching viz. APC(Alternative PHP Cache), file(file cache) and mem(memory cache). The cache data saved in the file is in the JSON format.
You can use any type of caching among the above three by just changing the value of $_[‘cache_type’] to ‘file’, ‘apc’ or ‘mem’ in system->config->default.php.
For creating cache, we have to use the following code:
Here, ‘cacheName’ is the name by which cache can be called and $cacheData is a variable in which the data is stored. In order to get the stored data, the following command will be used.
So, it’s very easy to use the cache. By default, Opencart mainly uses cache for currency and language. You can try it with different types too.