tp6中model的crd

2022-05-18 13:21:03 浏览数 (1)

create:

代码语言:javascript复制
<?php
namespace appindexcontroller;

use appBaseController;
use thinkfacadeDb;
use appmodelAaa;
use thinkfacadeCache;
class Index extends BaseController
{
    public function hello()
    {
    	//设置缓存
    	Cache::set("bj","您好",3600);
    	//获取缓存
    	$res=Cache::get("bj");
    	//输出缓存
    	halt($res);
    }
}

delete:

代码语言:javascript复制
<?php
namespace appindexcontroller;

use appBaseController;
use thinkfacadeDb;
use appmodelAaa;
use thinkfacadeCache;
class Index extends BaseController
{
    public function hello()
    {
    	//设置缓存
    	Cache::set("bj","您好",3600);
    	//删除缓存
    	Cache::delete('bj');
    	//获取缓存
    	$res=Cache::get("bj");
    	//输出缓存
    	halt($res);
    }
}

0 人点赞