mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
增加Test缓存驱动
This commit is contained in:
7
library/think/cache/driver/Apc.php
vendored
7
library/think/cache/driver/Apc.php
vendored
@@ -31,9 +31,7 @@ class Apc
|
||||
******************************/
|
||||
/**
|
||||
* 架构函数
|
||||
*
|
||||
* @param array $options 缓存参数
|
||||
*
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
@@ -97,11 +95,10 @@ class Apc
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**删除缓存
|
||||
/**
|
||||
* 删除缓存
|
||||
* @access public
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
*
|
||||
* @return bool|\string[]
|
||||
*/
|
||||
public function rm($name)
|
||||
|
||||
1
library/think/cache/driver/File.php
vendored
1
library/think/cache/driver/File.php
vendored
@@ -182,7 +182,6 @@ class File
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
|
||||
16
library/think/cache/driver/Lite.php
vendored
16
library/think/cache/driver/Lite.php
vendored
@@ -66,7 +66,7 @@ class Lite
|
||||
if (is_file($filename)) {
|
||||
// 判断是否过期
|
||||
$mtime = filemtime($filename);
|
||||
if ($mtime<time()) {
|
||||
if ($mtime < time()) {
|
||||
// 清除已经过期的文件
|
||||
unlink($filename);
|
||||
return false;
|
||||
@@ -80,22 +80,20 @@ class Lite
|
||||
/**
|
||||
* 写入缓存
|
||||
* @access public
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @internal param int $expire 有效时间 0为永久
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function set($name, $value, $expire=null)
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
Cache::$writeTimes++;
|
||||
if (is_null($expire)) {
|
||||
$expire = $this->options['expire'];
|
||||
}
|
||||
// 模拟永久
|
||||
if (0===$expire) {
|
||||
$expire = 10*365*24*3600;
|
||||
if (0 === $expire) {
|
||||
$expire = 10 * 365 * 24 * 3600;
|
||||
}
|
||||
$filename = $this->filename($name);
|
||||
// 缓存数据
|
||||
@@ -103,12 +101,12 @@ class Lite
|
||||
$dir = dirname($filename);
|
||||
// 目录不存在则创建
|
||||
if (!is_dir($dir))
|
||||
mkdir($dir,0755,true);
|
||||
*/
|
||||
mkdir($dir,0755,true);
|
||||
*/
|
||||
$ret = file_put_contents($filename, ("<?php return " . var_export($value, true) . ";"));
|
||||
// 通过设置修改时间实现有效期
|
||||
if ($ret) {
|
||||
touch($filename, time()+$expire);
|
||||
touch($filename, time() + $expire);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
2
library/think/cache/driver/Memcache.php
vendored
2
library/think/cache/driver/Memcache.php
vendored
@@ -110,10 +110,8 @@ class Memcache
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @param bool|false $ttl
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rm($name, $ttl = false)
|
||||
|
||||
2
library/think/cache/driver/Memcached.php
vendored
2
library/think/cache/driver/Memcached.php
vendored
@@ -111,10 +111,8 @@ class Memcached
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @param bool|false $ttl
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rm($name, $ttl = false)
|
||||
|
||||
2
library/think/cache/driver/Sae.php
vendored
2
library/think/cache/driver/Sae.php
vendored
@@ -89,10 +89,8 @@ class Sae
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @param bool|false $ttl
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rm($name, $ttl = false)
|
||||
|
||||
67
library/think/cache/driver/Test.php
vendored
Normal file
67
library/think/cache/driver/Test.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\cache\driver;
|
||||
|
||||
use think\Cache;
|
||||
|
||||
/**
|
||||
* 测试缓存类
|
||||
* @author liu21st <liu21st@gmail.com>
|
||||
*/
|
||||
class Test
|
||||
{
|
||||
|
||||
/**
|
||||
* 读取缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
2
library/think/cache/driver/Wincache.php
vendored
2
library/think/cache/driver/Wincache.php
vendored
@@ -29,9 +29,7 @@ class Wincache
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
*
|
||||
* @param array $options 缓存参数
|
||||
*
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user