From 1bab8ba6a0ab23f845a990a4bc8073eee8875a42 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 14 Sep 2016 16:05:01 +0800 Subject: [PATCH] =?UTF-8?q?Cache=E7=B1=BB=E5=A2=9E=E5=8A=A0pull=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=94=A8=E4=BA=8E=E8=8E=B7=E5=8F=96=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B9=B6=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/Driver.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/library/think/cache/Driver.php b/library/think/cache/Driver.php index 021ae727..f77ac30b 100644 --- a/library/think/cache/Driver.php +++ b/library/think/cache/Driver.php @@ -91,6 +91,23 @@ abstract class Driver return $this->options['prefix'] . $name; } + /** + * 读取缓存并删除 + * @access public + * @param string $name 缓存变量名 + * @return mixed + */ + public function pull($name) + { + $result = $this->get($name, false); + if ($result) { + $this->rm($name); + return $result; + } else { + return null; + } + } + /** * 缓存标签 * @access public