Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_storage_dataset.php
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | public function count() | ||||
return count($this->index); | return count($this->index); | ||||
} | } | ||||
/*** Implement PHP ArrayAccess interface ***/ | /*** Implement PHP ArrayAccess interface ***/ | ||||
public function offsetSet($offset, $value) | public function offsetSet($offset, $value) | ||||
{ | { | ||||
$uid = $value['_msguid']; | $uid = !empty($value['_msguid']) ? $value['_msguid'] : $value['uid']; | ||||
if (is_null($offset)) { | if (is_null($offset)) { | ||||
$offset = count($this->index); | $offset = count($this->index); | ||||
$this->index[] = $uid; | |||||
} | } | ||||
else { | |||||
$this->index[$offset] = $uid; | $this->index[$offset] = $uid; | ||||
} | |||||
// keep full payload data in memory if possible | // keep full payload data in memory if possible | ||||
if ($this->memlimit && $this->buffer && isset($value['_mailbox'])) { | if ($this->memlimit && $this->buffer) { | ||||
$this->data[$offset] = $value; | $this->data[$offset] = $value; | ||||
// check memory usage and stop buffering | // check memory usage and stop buffering | ||||
if ($offset % 10 == 0) { | if ($offset % 10 == 0) { | ||||
$this->buffer = memory_get_usage() < $this->memlimit; | $this->buffer = memory_get_usage() < $this->memlimit; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public function offsetExists($offset) | public function offsetExists($offset) | ||||
{ | { | ||||
return isset($this->index[$offset]); | return isset($this->index[$offset]); | ||||
} | } | ||||
public function offsetUnset($offset) | public function offsetUnset($offset) | ||||
{ | { | ||||
unset($this->index[$offset]); | unset($this->index[$offset]); | ||||
} | } | ||||
public function offsetGet($offset) | public function offsetGet($offset) | ||||
{ | { | ||||
if (isset($this->data[$offset])) { | if (isset($this->data[$offset])) { | ||||
return $this->data[$offset]; | return $this->data[$offset]; | ||||
} | } | ||||
else if ($msguid = $this->index[$offset]) { | |||||
return $this->cache->get($msguid); | if ($uid = $this->index[$offset]) { | ||||
return $this->cache->get($uid); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
/*** Implement PHP Iterator interface ***/ | /*** Implement PHP Iterator interface ***/ | ||||
Show All 26 Lines |