*
* @var Horde_Imap_Client_Cache
*/
- protected $_cacheOb = null;
+ protected $_cache = null;
/**
* The debug stream.
$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'])) {
*
* @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']
*
* @return mixed Either the object or null.
*/
- public function getCacheOb()
+ public function getCache()
{
- $this->_initCacheOb();
- return $this->_cacheOb;
+ $this->_initCache();
+ return $this->_cache;
}
/**
$this->_deleteMailbox($mailbox);
/* Delete mailbox cache. */
- if ($this->_initCacheOb()) {
- $this->_cacheOb->deleteMailbox($mailbox);
+ if ($this->_initCache()) {
+ $this->_cache->deleteMailbox($mailbox);
}
/* Unsubscribe from mailbox. */
$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. */
}
/* 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);
$this->_mode = 0;
if (!is_null($search_res)) {
- $this->_cacheOb->deleteMsgs($this->_selected, $search_res['match']);
+ $this->_cache->deleteMsgs($this->_selected, $search_res['match']);
}
}
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']);
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']));
}
}
/* 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;
*/
protected function _updateCache($data, $options = array())
{
- if (!$this->_initCacheOb()) {
+ if (!$this->_initCache()) {
return;
}
}
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) {
*
* @var Horde_Cache
*/
- protected $_cacheOb;
+ protected $_cache;
/**
* The list of items to save on shutdown.
}
/* 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;
$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);
}
}
{
$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']) {
$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;
}
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;
/* 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'];
}
if (!empty($expunged)) {
- $this->_cacheOb->deleteMsgs($this->_selected, $expunged);
+ $this->_cache->deleteMsgs($this->_selected, $expunged);
}
}
}
$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. */
/* 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
}
}
} elseif (!isset($this->_init['enabled']['CONDSTORE']) &&
- $this->_initCacheOb() &&
+ $this->_initCache() &&
$this->queryCapability('CONDSTORE')) {
/* Activate CONDSTORE now if ENABLE is not available. */
$cmd .= ' (CONDSTORE)';
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;
} 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);
}
$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:*';
}
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. */
* 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
/* 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();