Home CMS Tutorial ECShop Introducing ecshop clear mysql cache

Introducing ecshop clear mysql cache

Mar 15, 2021 am 10:25 AM
ecshop mysql cache

Introducing ecshop clear mysql cache

ECSHOP's cache is stored in the templates/caches/article folder. Over time, this folder will become very large and slow down the website. There are many situations where we don't need his cache. This article describes how to disable ECSHOP caching.

ECSHOP's cache has two parts, one is SMARTY's page cache; the other is the cache of SQL query results. Both parts are saved in the templates/caches/ folder. As long as we turn off these two functions respectively, we can completely disable ECSHOP's cache. Of course, you can also turn off one of them according to your needs.

Recommended (free): ecshop

1. Turn off SMARTY’s cache

Openincludes/cls_template.php, find the following paragraph

if (file_put_contents($this->cache_dir . ‘/’ . $cachename . ‘.php’, ‘<?php exit;?>’ . $data . $out) === false)
{
trigger_error(‘can’t write:’ . $this->cache_dir . ‘/’ . $cachename . ‘.php’);
}
Copy after login

--Comment out this code

2. Turn off the SQL query result cache

Openincludes/cls_mysql.php

Find

var $max_cache_time=3600;//最大的缓存时间,以秒为单位
Copy after login

Change to

var $max_cache_time=0;//最大的缓存时间,以秒为单位
Copy after login

How to limit or disable ECShop cache? Logically speaking, you only need to log in to the host space server via ftp and clear the cache files in the "templates/caches" folder. However, a safer and more secure way is to enter the ecshop online store backend and click the "Clear Cache" button in the upper right corner. Or completely disable ecshop's caching function.

1. Disable caching of some data tables in ecshop

The cache files in the caches folder in ecshop include sql query result cache and SMARTY template page cache. If there are many users visiting the website, these temporary cached data will be kept in the "templates/caches" folder of ECshop. Data caching plays a certain role in improving the speed of online stores, but too many cached files are too much. Some people say that caching can be disabled only for the two tables favourable_activity, goods_activity.

Open include/init.php, find

PHP code

$db->set_disable_cache_tables(array($ecs->table(’sessions’), $ecs->table(’sessions_data’), $ecs->table(’cart’)));
Copy after login

and modify it to

PHP code

$db->set_disable_cache_tables(array($ecs->table(’sessions’), $ecs->table(’sessions_data’), $ecs->table(’cart’), $ecs->table(’favourable_activity’), $ecs->table(’goods_activity’)));
Copy after login

two , completely disable the ecshop cache

You have to log in to the ecshop online store backend regularly to clear the cache files, which is quite troublesome for lazy people. Then simply disable ecshop caching completely. Refer to Xiao Chong's article on disabling echsop cache. Xiao Chong's specific code is around version 2.6.0. The method of disabling cache modification in 2.7 ecshop is similar:

1. Use editplus to open include/cls_template.php and comment out the following code:

PHP code

2. Use editplus Open include/cls_mysql.php, find max_cache_time = 300, and change 300 to 0

3. Can the files under templates/compiled be cleared?

templates The files under /compiled are template compiled files and can be cleared. It will be regenerated when the user browses the online store. The main problem in the templates folder is that there are too many cache files in the caches. You can clear the ecshop cache regularly or completely disable it.

----------------------------------------- --

Suggestions on clearing the cache!!

I found that the current clearing cache is relatively rough! There is no big change from before! It is the same as 2.0.5.

As long as there is any modification operation in the background, the entire cache will be gone! All used are $smarty->clear_all_cache();

Disadvantages: If I have 100,000 products and they have all been viewed, I A single operation in the background requires clearing more than 150,000 cached files:) It seems to be a bit extreme.

Just an example!! I hope ECSHOP will be more perfect!

Isn’t there this function in smarty?

clear_cache(), I made a small modification and added that you can specify to delete the cache in a certain directory. The purpose is: you can conveniently delete the category cache of the product!

I am on 2.0.5 This is changed, and a cache directory templates_caches is created in the root directory, and article, article_cat, goods, goods_cat are created in it. Four folders are used to store article content, article list, and product content. , Cache of product list

Example: Modification of products and articles

Add the following code to front-end init.php and back-end init.php. I added it directly to config.php for convenience.

//缓存目录设置
define(&#39;ECS_ROOT&#39;, substr(dirname(__FILE__), 0, -8));//前后台数字当然不一样了:)
//文章缓存
$cache_dir_article = ECS_ROOT.&#39;./templates_caches/article&#39;;
$cache_dir_article_cat = ECS_ROOT.&#39;./templates_caches/article_cat&#39;;
//商品缓存
$cache_dir_goods = ECS_ROOT.&#39;./templates_caches/goods&#39;;
$cache_dir_goods_cat = ECS_ROOT.&#39;./templates_caches/goods_cat&#39;;
Copy after login

The front-end product content and category cache time are separately set to be longer, such as one month for content and one day for category

Modify the backend, where the product is modified individually, only the cache of this product content is deleted

As long as there are modification operations, delete the product category cache and homepage cache! Add the following

$smarty->clear_cache(null, null, null, null, $cache_dir_goods_cat);//zouql:删除商品目录缓存,默认缓存时间
$smarty->clear_cache(&#39;goods.html&#39;, $goods_id, null, null, $cache_dir_goods);//zouql:删除商品缓存,默认缓存时间
Copy after login

There are also advertising management, etc., etc., etc., etc., etc., etc., etc. need to be changed!

Front desk user Automatically delete this product cache after posting a comment, etc.......

function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null, $cache_dir = null)
{
if (!isset($cache_dir))
$cache_dir = $this->cache_dir;
if (!isset($compile_id))
$compile_id = $this->compile_id;
if (!isset($tpl_file))
$compile_id = null;
$_auto_id = $this->_get_auto_id($cache_id, $compile_id);
if (!empty($this->cache_handler_func)) {
return call_user_func_array($this->cache_handler_func,
array(&#39;clear&#39;, &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time));
} else {
$_params = array(&#39;auto_base&#39; => $cache_dir,
&#39;auto_source&#39; => $tpl_file,
&#39;auto_id&#39; => $_auto_id,
&#39;exp_time&#39; => $exp_time);
require_once(SMARTY_CORE_DIR . &#39;core.rm_auto.php&#39;);
return smarty_core_rm_auto($_params, $this);
}
}
Copy after login

The above is the detailed content of Introducing ecshop clear mysql cache. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the architecture of ecshop? What is the architecture of ecshop? Feb 23, 2023 am 09:32 AM

ecshop is a "B2C" architecture; ecshop is a B2C independent online store system, suitable for enterprises and individuals to quickly build personalized online stores; the system is a cross-platform open source program developed based on PHP language and MYSQL database architecture.

What are the methods for sorting ecshop articles? What are the methods for sorting ecshop articles? Jun 16, 2023 am 11:30 AM

How to sort ecshop articles: 1. Sort by publication time, you can control the order of articles in the list by modifying the publication time of the article; 2. Sort by clicks, you can achieve this sorting by installing the "Article Click Ranking" plug-in Function, this plug-in can count the number of clicks on articles; 3. Sort by the number of comments, you can implement this sorting function by installing the "Article Comment Ranking" plug-in, which can count the number of comments on articles; 4. Sort by relevance, This sorting function can be achieved by installing the "Search Ranking" plug-in.

What are the characteristics of ecshop? What are the characteristics of ecshop? Feb 13, 2023 am 09:43 AM

Features: 1. Open source system with flexibility, customizability and high scalability; 2. Support independent secondary development; 3. Rich templates and plug-ins; 4. Strong industry adaptability; 5. Avoid being constrained by software vendors; 6. Stronger reliability and stability; 7. Mobile H5 framework upgrade, based on VUE comprehensive replacement, more flexible and open; 8. Multi-level rebate function, supporting QR codes, posters and other promotion methods, unlimited fission development of distributors ; 8. The visual interaction of the management terminal is completely renewed, the UI is simple and beautiful, and the operating experience is upgraded; 9. Supports PHP7.2, and the performance is doubled.

What program is ecshop? What program is ecshop? Feb 16, 2023 am 10:38 AM

ECShop is a B2C independent online store system. It is a cross-platform open source program developed based on PHP language and MYSQL database architecture. It is suitable for enterprises and individuals to quickly build personalized online stores. The characteristics of the ecshop mall system: 1. Support independent secondary development; 2. Rich templates and plug-ins; 3. Strong industry adaptability; 4. Avoid being constrained by software vendors; 5. Stronger reliability and stability.

What is the model of ecshop? What is the model of ecshop? Feb 22, 2023 am 09:37 AM

ecshop is a B2C model. ECShop is a B2C independent online store system, suitable for enterprises and individuals to quickly build personalized online stores. B2C refers to a model of e-commerce, and it is also a retail model that sells products and services directly to consumers; the payment method of B2C e-commerce is a combination of cash on delivery and online payment, and most companies choose logistics outsourcing for delivery. to save operating costs.

Ecshop product management advanced: learn how to add fields Ecshop product management advanced: learn how to add fields Mar 12, 2024 pm 02:06 PM

Ecshop Product Management Advanced: Learn how to add fields, you need specific code examples. When using Ecshop for product management, you often encounter situations where you need to add some custom fields to meet specific needs. By adding fields, more precise product management and better user experience can be achieved. This article will introduce how to add fields in Ecshop and provide specific code examples. First, we need to clarify the need to add fields. For example, we need to add a "production date" field to the product details page to

How to remove copyright at the bottom of ecshop How to remove copyright at the bottom of ecshop Aug 08, 2023 pm 02:42 PM

Method to remove the copyright at the bottom of ecshop: 1. Modify the template file, the specific location is: themes/your_theme directory, find the footer.html file in this directory, open it with a text editor, find the code segment containing the copyright information, delete it or Comment out. Just save the file and close it; 2. To use the plug-in, log in to the backend, click plug-in management, search for copyright and other related keywords at the bottom, select a suitable plug-in to install and enable it; 3. To purchase a theme, purchase it on the official website of ECShop etc.

How to cancel delivery method in ecshop How to cancel delivery method in ecshop Mar 03, 2023 am 09:56 AM

How to cancel the shipping method in ecshop: 1. Find and open the "flow.dwt" file, and then delete "<!--{if $total.real_goods_count neq 0}-->...<!-- {/if} - ->" code; 2. Change "checkOrderForm(frm)" in "js/shopping_flow.js" to "if (document.getElementById(...)".

See all articles