Cache Management¶
Set & Get Cache from Frontend:¶
<?php
public function getCategoriess() {
$category_data = $this->cache->get('category.frontend');
if (!$category_data) {
$s = $this->db->prepare("SELECT * FROM " . $_ENV['DB_PREFIX'] . "category WHERE status = '1' ORDER BY name ASC");
$s->execut();
$category_data = $s->fetchAll();
$this->cache->set('category.frontend', $category_data);
}
return $category_data;
}
Set & Get Cache from Backend:¶
<?php
public function getCategoriess() {
$category_data = $this->cache->get('category.backend');
if (!$category_data) {
$s = $this->db->prepare("SELECT * FROM " . $_ENV['DB_PREFIX'] . "category WHERE status = '1' ORDER BY name ASC");
$s->execut();
$category_data = $s->fetchAll();
$this->cache->set('category.backend', $category_data);
}
return $category_data;
}
Delete Cache frond Backend:¶
Explanation: $this->cache->delete(‘category’); the statement will delete all caches prefix with ‘category’ key. i.e. category.frontend, category.backend
Example:
<?php
public function addCategory($data) {
...
$this->cache->delete('category');
}
public function editCategory($category_id, $data) {
...
$this->cache->delete('category');
}
public function deleteCategory($category_id) {
...
$this->cache->delete('category');
}
How to clear all caches manually?¶
Open up the Cached folder (defined in config.php file). Delete all files in the cache folder.
You may want to delete all cached files in your browser too.