The following tutorial column of thinkphp framework will introduce to you how to clear the cache, template cache and log cache of thinkphp5. I hope it will be helpful to friends in need!
Write directly into the cache module to generate the controller
namespace app\cache\controller; use think\Controller; use think\Cache;
The specific method is as follows:
public function Index() { return $this->fetch(); } //清除模版缓存不删除cache目录; public function clear_sys_cache() { Cache::clear(); $this->success('清除成功', 'Index/index'); } //清除模版缓存但不删除temp目录; public function clear_temp_ahce() { $path = glob(TEMP_PATH . '*.php'); array_map('unlink', $path); $this->success('清除成功', 'Index/index'); } //清除日志缓存并删出log空目录; public function clear_log_chache() { $path = glob(LOG_PATH . '*'); foreach ($path as $item) { //dump(glob($item .DS. '*.log')); array_map('unlink', glob($item . DS . '*.log')); rmdir($item); } $this->success('清除成功', 'Index/index'); }
The main php functions used are:
array_map ( callback , array1 , array... )
array_map --Apply callback to each element of the array Drop function
Parameter 1: Drop function, applied to each element in each array
Parameter 2: Array, convenient for running the function set by parameter 1
Return Array, containing all elements of array1 after processing by the callback function.
glob(pattern,flags)
The above is the detailed content of thinkphp5 clear cache, template cache and log cache. For more information, please follow other related articles on the PHP Chinese website!

The article discusses ThinkPHP's built-in testing framework, highlighting its key features like unit and integration testing, and how it enhances application reliability through early bug detection and improved code quality.

Article discusses using ThinkPHP for real-time stock market data feeds, focusing on setup, data accuracy, optimization, and security measures.

The article discusses key considerations for using ThinkPHP in serverless architectures, focusing on performance optimization, stateless design, and security. It highlights benefits like cost efficiency and scalability, but also addresses challenges

The article discusses implementing service discovery and load balancing in ThinkPHP microservices, focusing on setup, best practices, integration methods, and recommended tools.[159 characters]

ThinkPHP's IoC container offers advanced features like lazy loading, contextual binding, and method injection for efficient dependency management in PHP apps.Character count: 159

The article discusses using ThinkPHP to build real-time collaboration tools, focusing on setup, WebSocket integration, and security best practices.

ThinkPHP benefits SaaS apps with its lightweight design, MVC architecture, and extensibility. It enhances scalability, speeds development, and improves security through various features.

The article outlines building a distributed task queue system using ThinkPHP and RabbitMQ, focusing on installation, configuration, task management, and scalability. Key issues include ensuring high availability, avoiding common pitfalls like imprope


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function