Zhu Jinhui 7 سال پیش
والد
کامیت
fc6fce6fa5
2فایلهای تغییر یافته به همراه8 افزوده شده و 11 حذف شده
  1. 2 2
      Qii/Base/Controller.php
  2. 6 9
      Qii/Library/Third/WhichBrowser/Cache.php

+ 2 - 2
Qii/Base/Controller.php

@@ -6,8 +6,8 @@ namespace Qii\Base;
 
 use \Qii\Autoloader\Psr4;
 
-use \Qi\Config\Register;
-use \Qi\Config\Consts;
+use \Qii\Config\Register;
+use \Qii\Config\Consts;
 
 /**
  * Qii_Controller_Abstract class

+ 6 - 9
Qii/Library/Third/WhichBrowser/Cache.php

@@ -89,19 +89,16 @@ trait Cache
             }
         }
 
-        if ($this->cache instanceof CacheItemPoolInterface) {
-            $item = $this->cache->getItem('whichbrowser_' . md5(serialize($headers)));
-
-            if ($item->isHit()) {
-                $this->applyCachedData($item->get());
+        if ($this->cache instanceof \Qii\Cache\Memcache) {
+            $cacheId = 'whichbrowser_' . md5(serialize($headers));
+            $item = unserialize($this->cache->get($cacheId));
+            if ($item) {
+                $this->applyCachedData($item);
             } else {
                 $analyser = new Analyser($headers, $options);
                 $analyser->setdata($this);
                 $analyser->analyse();
-
-                $item->set($this->retrieveCachedData());
-                $item->expiresAfter($this->expires);
-                $this->cache->save($item);
+                $this->cache->set($cacheId, serialize($this->retrieveCachedData()), ['expired' => time() + $this->expires]);
             }
 
             return true;