erp_old/app/common/cache/BaseCache.php

47 lines
824 B
PHP
Raw Normal View History

2023-02-28 15:13:10 +08:00
<?php
namespace app\common\cache;
2023-09-20 13:54:09 +08:00
use support\Cache;
2023-02-28 15:13:10 +08:00
class BaseCache
{
/**
* 缓存标签
* @var string
*/
protected $tagName;
protected $cache;
public function __construct(){
$this->tagName = get_class($this);
}
/**
* @notes 重写父类set自动打上标签
* @param string $key
* @param mixed $value
* @param null $ttl
* @return bool
* @author 乔峰
* @date 2021/12/27 14:16
*/
public function set($key, $value, $ttl = null): bool
{
2023-09-20 13:54:09 +08:00
return Cache::set($key, $value, $ttl);
2023-02-28 15:13:10 +08:00
}
/**
* @notes 清除缓存类所有缓存
* @return bool
* @author 乔峰
* @date 2021/12/27 14:16
*/
public function deleteTag(): bool
{
2023-09-20 13:54:09 +08:00
return Cache::delete($this->tagName);
2023-02-28 15:13:10 +08:00
}
}