修改cache注释
This commit is contained in:
parent
85ddec7fdd
commit
f2d8ac626e
|
@ -17,7 +17,6 @@ class File implements CacheIfs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前实例
|
* 当前实例
|
||||||
* @var
|
|
||||||
*/
|
*/
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
|
@ -29,16 +28,16 @@ class File implements CacheIfs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认缓存位置
|
* 默认缓存位置
|
||||||
* @var null|string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $dir = './runtime/data/';
|
private $dir = './runtime/data/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复写获取单一实例方法
|
* 复写获取单一实例方法
|
||||||
* @param null $dir
|
* @param string $dir
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function instance($dir = null)
|
public static function instance($dir = '')
|
||||||
{
|
{
|
||||||
$ident = md5($dir);
|
$ident = md5($dir);
|
||||||
if (!isset(self::$instance[$ident])) {
|
if (!isset(self::$instance[$ident])) {
|
||||||
|
@ -50,9 +49,9 @@ class File implements CacheIfs
|
||||||
/**
|
/**
|
||||||
* 进行一些初始化操作
|
* 进行一些初始化操作
|
||||||
* File constructor.
|
* File constructor.
|
||||||
* @param null $dir
|
* @param string $dir
|
||||||
*/
|
*/
|
||||||
private function __construct($dir = null)
|
private function __construct($dir = '')
|
||||||
{
|
{
|
||||||
if ($dir) {
|
if ($dir) {
|
||||||
$this->dir = $dir;
|
$this->dir = $dir;
|
||||||
|
@ -89,7 +88,7 @@ class File implements CacheIfs
|
||||||
* @param null $callable
|
* @param null $callable
|
||||||
* @return bool|false|string
|
* @return bool|false|string
|
||||||
*/
|
*/
|
||||||
public function get($key = null, $callable = null)
|
public function get($key, $callable = null)
|
||||||
{
|
{
|
||||||
// 判断缓存是否存在
|
// 判断缓存是否存在
|
||||||
if ($this->exists($key)) {
|
if ($this->exists($key)) {
|
||||||
|
@ -107,7 +106,7 @@ class File implements CacheIfs
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function remove($key = null)
|
public function remove($key)
|
||||||
{
|
{
|
||||||
$filename = $this->getFileName($key);
|
$filename = $this->getFileName($key);
|
||||||
if (is_file($filename)) {
|
if (is_file($filename)) {
|
||||||
|
@ -118,7 +117,7 @@ class File implements CacheIfs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断缓存是否存在/有效
|
* 判断缓存是否存在/有效
|
||||||
* @param $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function exists($key)
|
public function exists($key)
|
||||||
|
@ -132,7 +131,7 @@ class File implements CacheIfs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件缓存内容
|
* 获取文件缓存内容
|
||||||
* @param $key
|
* @param string $key
|
||||||
* @return false|string
|
* @return false|string
|
||||||
*/
|
*/
|
||||||
private function getCacheContent($key)
|
private function getCacheContent($key)
|
||||||
|
@ -143,7 +142,7 @@ class File implements CacheIfs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断缓存是否超时
|
* 判断缓存是否超时
|
||||||
* @param $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function timeOut($key)
|
private function timeOut($key)
|
||||||
|
@ -169,7 +168,7 @@ class File implements CacheIfs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取缓存文件
|
* 读取缓存文件
|
||||||
* @param $key
|
* @param string $key
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function readCacheFile($key)
|
private function readCacheFile($key)
|
||||||
|
|
|
@ -63,11 +63,11 @@ class Redis implements CacheIfs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取缓存的值
|
* 获取缓存的值
|
||||||
* @param null $key
|
* @param string $key
|
||||||
* @param null $callable
|
* @param string $callable
|
||||||
* @return bool|mixed|string
|
* @return bool|mixed|string
|
||||||
*/
|
*/
|
||||||
public function get($key = null, $callable = null)
|
public function get($key, $callable = null)
|
||||||
{
|
{
|
||||||
$status = $this->exists($key);
|
$status = $this->exists($key);
|
||||||
$value = $status ? $this->redis->get($key) : false;
|
$value = $status ? $this->redis->get($key) : false;
|
||||||
|
@ -89,7 +89,7 @@ class Redis implements CacheIfs
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function remove($key = null)
|
public function remove($key)
|
||||||
{
|
{
|
||||||
return $this->redis->del($key);
|
return $this->redis->del($key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ namespace top\library\cache\ifs;
|
||||||
interface CacheIfs
|
interface CacheIfs
|
||||||
{
|
{
|
||||||
|
|
||||||
public function set($name, $value, $timeout = null);
|
public function set($key, $value, $timeout = 0);
|
||||||
|
|
||||||
public function get($name = null, $callable = null);
|
public function get($key, $callable = null);
|
||||||
|
|
||||||
public function remove($name = null);
|
public function remove($key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue