diff --git a/library/think/cache/driver/File.php b/library/think/cache/driver/File.php index 04d8c4a6..f02f6e7a 100644 --- a/library/think/cache/driver/File.php +++ b/library/think/cache/driver/File.php @@ -129,7 +129,7 @@ class File extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|DateTime $expire 有效时间(秒) + * @param integer|\DateTime $expire 有效时间(秒) * @return boolean */ public function set($name, $value, $expire = null) diff --git a/library/think/cache/driver/Lite.php b/library/think/cache/driver/Lite.php index ca69489f..2e541851 100644 --- a/library/think/cache/driver/Lite.php +++ b/library/think/cache/driver/Lite.php @@ -93,7 +93,7 @@ class Lite extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|DateTime $expire 有效时间(秒) + * @param integer|\DateTime $expire 有效时间(秒) * @return bool */ public function set($name, $value, $expire = null) diff --git a/library/think/cache/driver/Memcache.php b/library/think/cache/driver/Memcache.php index 816e5a93..dcedec36 100644 --- a/library/think/cache/driver/Memcache.php +++ b/library/think/cache/driver/Memcache.php @@ -84,7 +84,7 @@ class Memcache extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|DateTime $expire 有效时间(秒) + * @param integer|\DateTime $expire 有效时间(秒) * @return bool */ public function set($name, $value, $expire = null) diff --git a/library/think/cache/driver/Memcached.php b/library/think/cache/driver/Memcached.php index 6232fd80..1032e254 100644 --- a/library/think/cache/driver/Memcached.php +++ b/library/think/cache/driver/Memcached.php @@ -95,7 +95,7 @@ class Memcached extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|DateTime $expire 有效时间(秒) + * @param integer|\DateTime $expire 有效时间(秒) * @return bool */ public function set($name, $value, $expire = null) diff --git a/library/think/cache/driver/Redis.php b/library/think/cache/driver/Redis.php index d2bba3ed..2b05dcc0 100644 --- a/library/think/cache/driver/Redis.php +++ b/library/think/cache/driver/Redis.php @@ -93,7 +93,7 @@ class Redis extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|DateTime $expire 有效时间(秒) + * @param integer|\DateTime $expire 有效时间(秒) * @return boolean */ public function set($name, $value, $expire = null) diff --git a/library/think/cache/driver/Sqlite.php b/library/think/cache/driver/Sqlite.php index 74f0b66f..dd7cc957 100644 --- a/library/think/cache/driver/Sqlite.php +++ b/library/think/cache/driver/Sqlite.php @@ -98,7 +98,7 @@ class Sqlite extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|DateTime $expire 有效时间(秒) + * @param integer|\DateTime $expire 有效时间(秒) * @return boolean */ public function set($name, $value, $expire = null) diff --git a/library/think/cache/driver/Wincache.php b/library/think/cache/driver/Wincache.php index aa56f6a7..77b8722d 100644 --- a/library/think/cache/driver/Wincache.php +++ b/library/think/cache/driver/Wincache.php @@ -70,7 +70,7 @@ class Wincache extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|DateTime $expire 有效时间(秒) + * @param integer|\DateTime $expire 有效时间(秒) * @return boolean */ public function set($name, $value, $expire = null) diff --git a/library/think/cache/driver/Xcache.php b/library/think/cache/driver/Xcache.php index c0b3a64c..06754445 100644 --- a/library/think/cache/driver/Xcache.php +++ b/library/think/cache/driver/Xcache.php @@ -70,7 +70,7 @@ class Xcache extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|DateTime $expire 有效时间(秒) + * @param integer|\DateTime $expire 有效时间(秒) * @return boolean */ public function set($name, $value, $expire = null) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 527008a5..a5072fc8 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1446,18 +1446,19 @@ class Query /** * 查询缓存 * @access public - * @param mixed $key 缓存key - * @param integer $expire 缓存有效期 - * @param string $tag 缓存标签 + * @param mixed $key 缓存key + * @param integer|\DateTime $expire 缓存有效期 + * @param string $tag 缓存标签 * @return $this */ public function cache($key = true, $expire = null, $tag = null) { // 增加快捷调用方式 cache(10) 等同于 cache(true, 10) - if (is_numeric($key) && is_null($expire)) { + if ($key instanceof \DateTime || (is_numeric($key) && is_null($expire))) { $expire = $key; $key = true; } + if (false !== $key) { $this->options['cache'] = ['key' => $key, 'expire' => $expire, 'tag' => $tag]; }