Thinkphp cache usage: 1. Use model query, with code statements such as "$data = SlsjList::alias('l') ->LEFTJOIN('suit_explain e','l.suit_two=e .name_two')"; 2. Cache via "Cache::store('redis')->set('list',$adata);".
The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.
thinkphp What is caching usage?
thinkphp cache usage method
The first code is our normal query method
The second one is in our own Create the method under the cache controller
The cache must be run for storage before it can be queried
Because the array is stored, the array must be encoded and decoded
//查询缓存,list是缓存时的名字 $list = Cache::store('redis')->get('list'); $list = json_decode($list);//解码 foreach($list as $key){ //for循环 $key = (array)$key;//对象转数组 $data[] =$key; } return json($data);
// 查询列表全部----- $data = SlsjList::alias('l')//用的是模型查询 ->LEFTJOIN('suit_explain e','l.suit_two=e.name_two') ->select();//数据库多表查询 $data = $data->toArray();//调用toArray方法转数组 $adata = json_encode($data);//编码 // 缓存列表 Cache::store('redis')->set('list',$adata);//缓存
Recommended learning: "thinkPHP Video Tutorial"
The above is the detailed content of What is thinkphp cache usage?. 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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools

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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor