cacheOb -> cache
authorChuck Hagenbuch <chuck@horde.org>
Thu, 15 Jan 2009 05:53:22 +0000 (00:53 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Thu, 15 Jan 2009 05:55:07 +0000 (00:55 -0500)
framework/Imap_Client/lib/Horde/Imap/Client/Base.php
framework/Imap_Client/lib/Horde/Imap/Client/Cache.php
framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php
framework/Imap_Client/lib/Horde/Imap/Client/Socket.php

index 41fe0e5..5a6dfa8 100644 (file)
@@ -73,7 +73,7 @@ abstract class Horde_Imap_Client_Base
      *
      * @var Horde_Imap_Client_Cache
      */
-    protected $_cacheOb = null;
+    protected $_cache = null;
 
     /**
      * The debug stream.
@@ -145,7 +145,7 @@ abstract class Horde_Imap_Client_Base
         $this->_closeDebug();
 
         // Don't store Horde_Imap_Client_Cache object.
-        $this->_cacheOb = null;
+        $this->_cache = null;
 
         // Encrypt password in serialized object.
         if (!isset($this->_params['_passencrypt'])) {
@@ -190,15 +190,15 @@ abstract class Horde_Imap_Client_Base
      *
      * @return boolean  Returns true if caching is enabled.
      */
-    protected function _initCacheOb()
+    protected function _initCache()
     {
         if (empty($this->_params['cache']['fields'])) {
             return false;
         }
 
-        if (is_null($this->_cacheOb)) {
+        if (is_null($this->_cache)) {
             $p = $this->_params;
-            $this->_cacheOb = Horde_Imap_Client_Cache::singleton(array_merge($p['cache'], array(
+            $this->_cache = Horde_Imap_Client_Cache::singleton(array_merge($p['cache'], array(
                 'debug' => $this->_debug,
                 'hostspec' => $p['hostspec'],
                 'username' => $p['username']
@@ -225,10 +225,10 @@ abstract class Horde_Imap_Client_Base
      *
      * @return mixed  Either the object or null.
      */
-    public function getCacheOb()
+    public function getCache()
     {
-        $this->_initCacheOb();
-        return $this->_cacheOb;
+        $this->_initCache();
+        return $this->_cache;
     }
 
     /**
@@ -682,8 +682,8 @@ abstract class Horde_Imap_Client_Base
         $this->_deleteMailbox($mailbox);
 
         /* Delete mailbox cache. */
-        if ($this->_initCacheOb()) {
-            $this->_cacheOb->deleteMailbox($mailbox);
+        if ($this->_initCache()) {
+            $this->_cache->deleteMailbox($mailbox);
         }
 
         /* Unsubscribe from mailbox. */
@@ -722,8 +722,8 @@ abstract class Horde_Imap_Client_Base
         $this->_renameMailbox($old, $new);
 
         /* Delete mailbox cache. */
-        if ($this->_initCacheOb()) {
-            $this->_cacheOb->deleteMailbox($old);
+        if ($this->_initCache()) {
+            $this->_cache->deleteMailbox($old);
         }
 
         /* Clean up subscription information. */
@@ -1046,7 +1046,7 @@ abstract class Horde_Imap_Client_Base
         }
 
         /* If we are caching, search for deleted messages. */
-        if (!empty($options['expunge']) && $this->_initCacheOb()) {
+        if (!empty($options['expunge']) && $this->_initCache()) {
             $search_query = new Horde_Imap_Client_Search_Query();
             $search_query->flag('\\deleted', true);
             $search_res = $this->search($this->_selected, $search_query);
@@ -1059,7 +1059,7 @@ abstract class Horde_Imap_Client_Base
         $this->_mode = 0;
 
         if (!is_null($search_res)) {
-            $this->_cacheOb->deleteMsgs($this->_selected, $search_res['match']);
+            $this->_cache->deleteMsgs($this->_selected, $search_res['match']);
         }
     }
 
@@ -1697,7 +1697,7 @@ abstract class Horde_Imap_Client_Base
     public function fetch($mailbox, $criteria, $options = array())
     {
         $cache_array = $get_fields = $new_criteria = $ret = array();
-        $cf = $this->_initCacheOb() ? $this->_params['cache']['fields'] : array();
+        $cf = $this->_initCache() ? $this->_params['cache']['fields'] : array();
         $qresync = isset($this->_init['enabled']['QRESYNC']);
         $seq = !empty($options['sequence']);
 
@@ -1762,14 +1762,14 @@ abstract class Horde_Imap_Client_Base
                     if (!$qresync) {
                         /* Grab all flags updated since the cached modseq
                          * val. */
-                        $metadata = $this->_cacheOb->getMetaData($this->_selected, array('HICmodseq'));
+                        $metadata = $this->_cache->getMetaData($this->_selected, array('HICmodseq'));
                         if (isset($metadata['HICmodseq']) &&
                             ($metadata['HICmodseq'] != $status_res['highestmodseq'])) {
-                            $uids = $this->_cacheOb->get($this->_selected, array(), array(), $status_res['uidvalidity']);
+                            $uids = $this->_cache->get($this->_selected, array(), array(), $status_res['uidvalidity']);
                             if (!empty($uids)) {
                                 $this->_fetch(array(Horde_Imap_Client::FETCH_FLAGS => true), array('changedsince' => $metadata['HICmodseq'], 'ids' => $uids));
                             }
-                            $this->_cacheOb->setMetaData($mailbox, array('HICmodseq' => $status_res['highestmodseq']));
+                            $this->_cache->setMetaData($mailbox, array('HICmodseq' => $status_res['highestmodseq']));
                         }
                     }
 
@@ -1825,7 +1825,7 @@ abstract class Horde_Imap_Client_Base
 
         /* Get the cached values. */
         try {
-            $data = $this->_cacheOb->get($this->_selected, $uids, $get_fields, $status_res['uidvalidity']);
+            $data = $this->_cache->get($this->_selected, $uids, $get_fields, $status_res['uidvalidity']);
         } catch (Horde_Imap_Client_Exception $e) {
             if ($e->getCode() != Horde_Imap_Client_Exception::CACHEUIDINVALID) {
                 throw $e;
@@ -2266,7 +2266,7 @@ abstract class Horde_Imap_Client_Base
      */
     protected function _updateCache($data, $options = array())
     {
-        if (!$this->_initCacheOb()) {
+        if (!$this->_initCache()) {
             return;
         }
 
@@ -2348,9 +2348,9 @@ abstract class Horde_Imap_Client_Base
         }
 
         try {
-            $this->_cacheOb->set($mailbox, $tocache, $uidvalid);
+            $this->_cache->set($mailbox, $tocache, $uidvalid);
             if ($is_flags) {
-                $this->_cacheOb->setMetaData($mailbox, array('HICmodseq' => max($highestmodseq)));
+                $this->_cache->setMetaData($mailbox, array('HICmodseq' => max($highestmodseq)));
             }
         } catch (Horde_Imap_Client_Exception $e) {
             if ($e->getCode() != Horde_Imap_Client_Exception::CACHEUIDINVALID) {
index 55c2f16..31a10e2 100644 (file)
@@ -48,7 +48,7 @@ class Horde_Imap_Client_Cache
      *
      * @var Horde_Cache
      */
-    protected $_cacheOb;
+    protected $_cache;
 
     /**
      * The list of items to save on shutdown.
@@ -114,9 +114,9 @@ class Horde_Imap_Client_Cache
         }
 
         /* Initialize the Cache object. */
-        $this->_cacheOb = Horde_Cache::singleton($params['driver'], $params['driver_params']);
-        if (is_a($this->_cacheOb, 'PEAR_Error')) {
-            throw new Horde_Imap_Client_Exception($this->_cacheOb->getMessage());
+        $this->_cache = Horde_Cache::singleton($params['driver'], $params['driver_params']);
+        if (is_a($this->_cache, 'PEAR_Error')) {
+            throw new Horde_Imap_Client_Exception($this->_cache->getMessage());
         }
 
         $compress = null;
@@ -179,14 +179,14 @@ class Horde_Imap_Client_Cache
                 $cid = $this->_getCID($mbox, $slice);
                 if (empty($data)) {
                     // If empty, we can expire the cache.
-                    $this->_cacheOb->expire($cid);
+                    $this->_cache->expire($cid);
                 } else {
-                    $this->_cacheOb->set($cid, Horde_Serialize::serialize($data, SERIALIZE_BASIC), $lifetime);
+                    $this->_cache->set($cid, Horde_Serialize::serialize($data, SERIALIZE_BASIC), $lifetime);
                 }
             }
 
             // Save the slicemap
-            $this->_cacheOb->set($this->_getCID($mbox, 'slicemap'), Horde_Serialize::serialize($sptr, SERIALIZE_BASIC), $lifetime);
+            $this->_cache->set($this->_getCID($mbox, 'slicemap'), Horde_Serialize::serialize($sptr, SERIALIZE_BASIC), $lifetime);
         }
     }
 
@@ -391,9 +391,9 @@ class Horde_Imap_Client_Cache
     {
         $this->_loadSliceMap($mbox);
         foreach (array_keys(array_flip($this->_slicemap[$mbox]['slice'])) as $slice) {
-            $this->_cacheOb->expire($this->_getCID($mbox, $slice));
+            $this->_cache->expire($this->_getCID($mbox, $slice));
         }
-        $this->_cacheOb->expire($this->_getCID($mbox, 'slicemap'));
+        $this->_cache->expire($this->_getCID($mbox, 'slicemap'));
         unset($this->_data[$mbox], $this->_loaded[$mbox], $this->_save[$mbox], $this->_slicemap[$mbox]);
 
         if ($this->_params['debug']) {
@@ -440,7 +440,7 @@ class Horde_Imap_Client_Cache
         $this->_loaded[$cache_id] = true;
 
         /* Attempt to grab data from the cache. */
-        if (($data = $this->_cacheOb->get($cache_id, $this->_params['lifetime'])) === false) {
+        if (($data = $this->_cache->get($cache_id, $this->_params['lifetime'])) === false) {
             return;
         }
 
@@ -569,7 +569,7 @@ class Horde_Imap_Client_Cache
     protected function _loadSliceMap($mailbox, $uidvalid = null)
     {
         if (!isset($this->_slicemap[$mailbox])) {
-            if (($data = $this->_cacheOb->get($this->_getCID($mailbox, 'slicemap'), $this->_params['lifetime'])) !== false) {
+            if (($data = $this->_cache->get($this->_getCID($mailbox, 'slicemap'), $this->_params['lifetime'])) !== false) {
                 $slice = Horde_Serialize::unserialize($data, SERIALIZE_BASIC);
                 if (is_array($slice)) {
                     $this->_slicemap[$mailbox] = $slice;
index b9c071e..607d581 100644 (file)
@@ -715,7 +715,7 @@ class Horde_Imap_Client_Cclient extends Horde_Imap_Client_Base
 
             /* If we are using a cache, we need to get the list of
              * messages that will be expunged. */
-            if ($this->_initCacheOb()) {
+            if ($this->_initCache()) {
                 if ($use_seq) {
                     $res = $this->search($this->_selected, $search_query);
                     $expunged = $res['match'];
@@ -724,7 +724,7 @@ class Horde_Imap_Client_Cclient extends Horde_Imap_Client_Base
                 }
 
                 if (!empty($expunged)) {
-                    $this->_cacheOb->deleteMsgs($this->_selected, $expunged);
+                    $this->_cache->deleteMsgs($this->_selected, $expunged);
                 }
             }
         }
index 9a40038..38cf0cb 100644 (file)
@@ -568,7 +568,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
         $this->setLanguage();
 
         /* Only active QRESYNC/CONDSTORE if caching is enabled. */
-        if ($this->_initCacheOb()) {
+        if ($this->_initCache()) {
             if ($this->queryCapability('QRESYNC')) {
                 /* QRESYNC REQUIRES ENABLE, so we just need to send one ENABLE
                  * QRESYNC call to enable both QRESYNC && CONDSTORE. */
@@ -780,10 +780,10 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
 
         /* If QRESYNC is available, synchronize the mailbox. */
         if ($qresync) {
-            $this->_initCacheOb();
-            $metadata = $this->_cacheOb->getMetaData($mailbox, array('HICmodseq', 'uidvalid'));
+            $this->_initCache();
+            $metadata = $this->_cache->getMetaData($mailbox, array('HICmodseq', 'uidvalid'));
             if (isset($metadata['HICmodseq'])) {
-                $uids = $this->_cacheOb->get($mailbox);
+                $uids = $this->_cache->get($mailbox);
                 if (!empty($uids)) {
                     /* This command may cause several things to happen.
                      * 1. UIDVALIDITY may have changed.  If so, we need
@@ -799,7 +799,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
                 }
             }
         } elseif (!isset($this->_init['enabled']['CONDSTORE']) &&
-                  $this->_initCacheOb() &&
+                  $this->_initCache() &&
                   $this->queryCapability('CONDSTORE')) {
             /* Activate CONDSTORE now if ENABLE is not available. */
             $cmd .= ' (CONDSTORE)';
@@ -821,11 +821,11 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
         if ($qresync && isset($metadata['uidvalid'])) {
             if (is_null($this->_temp['mailbox']['highestmodseq']) ||
                 ($this->_temp['mailbox']['uidvalidity'] != $metadata['uidvalid'])) {
-                $this->_cacheOb->deleteMailbox($mailbox);
+                $this->_cache->deleteMailbox($mailbox);
             } else {
                 /* We know the mailbox has been updated, so update the
                  * highestmodseq metadata in the cache. */
-                $this->_cacheOb->setMetaData($mailbox, array('HICmodseq' => $this->_temp['mailbox']['highestmodseq']));
+                $this->_cache->setMetaData($mailbox, array('HICmodseq' => $this->_temp['mailbox']['highestmodseq']));
             }
         } elseif ($condstore) {
             $this->_init['enabled']['CONDSTORE'] = true;
@@ -1266,7 +1266,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
         } else {
             // If caching, we need to know the UIDs being deleted, so call
             // expunge() before calling close().
-            if ($this->_initCacheOb()) {
+            if ($this->_initCache()) {
                 $this->expunge($this->_selected);
             }
 
@@ -1294,7 +1294,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
         $seq = !empty($options['sequence']);
         $s_res = null;
         $uidplus = $this->queryCapability('UIDPLUS');
-        $use_cache = $this->_initCacheOb();
+        $use_cache = $this->_initCache();
 
         if (empty($options['ids'])) {
             $uid_string = '1:*';
@@ -1374,12 +1374,12 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
             }
 
             if (!empty($expunged)) {
-                $this->_cacheOb->deleteMsgs($mailbox, $expunged);
+                $this->_cache->deleteMsgs($mailbox, $expunged);
                 $tmp['mailbox']['messages'] -= $i;
             }
 
             if (isset($this->_init['enabled']['QRESYNC'])) {
-                $this->_cacheOb->setMetaData($mailbox, array('HICmodseq' => $this->_temp['mailbox']['highestmodseq']));
+                $this->_cache->setMetaData($mailbox, array('HICmodseq' => $this->_temp['mailbox']['highestmodseq']));
             }
         } elseif (!empty($tmp['expunge'])) {
             /* Updates status message count if not using cache. */
@@ -1412,7 +1412,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
          * the tagged response. */
         if (is_array($data[0])) {
             if (strtoupper(reset($data[0])) == 'EARLIER') {
-                $this->_cacheOb->deleteMsgs($this->_temp['mailbox']['name'], $this->_utils->fromSequenceString($data[1]));
+                $this->_cache->deleteMsgs($this->_temp['mailbox']['name'], $this->_utils->fromSequenceString($data[1]));
             }
         } else {
             /* The second form is just VANISHED. This is returned from an
@@ -2634,7 +2634,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
 
             /* Get the list of flags from the cache. */
             if (empty($options['replace'])) {
-                $data = $this->_cacheOb->get($this->_selected, array_keys($uids), array('HICflags'), $this->_temp['mailbox']['uidvalidity']);
+                $data = $this->_cache->get($this->_selected, array_keys($uids), array('HICflags'), $this->_temp['mailbox']['uidvalidity']);
 
                 foreach ($uids as $uid => $modseq) {
                     $flags = isset($data[$uid]['HICflags']) ? $data[$uid]['HICflags'] : array();