}
/**
+ * Retrieve list data.
+ *
+ * @param string $connection_id ID of the connection matching the list.
+ * @param string $key Access key to the cached data.
+ *
+ * @return mixed The data of the object.
+ */
+ public function loadListData($connection_id, $key)
+ {
+ return $this->horde_cache->get($this->_getListKey($connection_id, $key), 0);
+ }
+
+ /**
+ * Cache list data.
+ *
+ * @param string $connection_id ID of the connection matching the list.
+ * @param string $key Access key to the cached data.
+ * @param string $data The data to be cached.
+ *
+ * @return boolean True if successfull.
+ */
+ public function storeListData($connection_id, $key, $data)
+ {
+ $this->horde_cache->set($this->_getListKey($connection_id, $key), $data);
+ }
+
+ /**
+ * Retrieve list data.
+ *
+ * @param string $connection_id ID of the connection matching the list.
+ * @param string $key Access key to the cached data.
+ *
+ * @return mixed The data of the object.
+ */
+ private function _getListKey($connection_id, $key)
+ {
+ return $connection_id . ':LIST:' . $key;
+ }
+
+ /**
* Load a cached attachment.
*
* @param string $key Access key to the cached data.
$this->assertEquals(false, $cache->uids[11]);
}
- /**
- * Test storing/loading attachments.
- *
- * @return NULL
- */
- public function testAttachments()
+ public function testLoadAttachment()
{
$cache = new Horde_Kolab_Storage_Cache($this->cache);
$cache->storeAttachment('a', 'attachment');
$this->assertEquals('attachment', $cache->loadAttachment('a'));
+ }
+
+ public function testLoadSecondAttachment()
+ {
+ $cache = new Horde_Kolab_Storage_Cache($this->cache);
+ $cache->storeAttachment('a', 'attachment');
$cache->storeAttachment('b', 'b');
$this->assertEquals('b', $cache->loadAttachment('b'));
+ }
+
+ public function testOverrideAttachment()
+ {
+ $cache = new Horde_Kolab_Storage_Cache($this->cache);
+ $cache->storeAttachment('a', 'attachment');
$cache->storeAttachment('a', 'a');
$this->assertEquals('a', $cache->loadAttachment('a'));
}
+ public function testCachingListData()
+ {
+ $cache = new Horde_Kolab_Storage_Cache($this->cache);
+ $cache->storeListData('user@example.com:143', 'folders', array('a', 'b'));
+ $this->assertEquals(array('a', 'b'), $cache->loadListData('user@example.com:143', 'folders'));
+ }
+
/**
* Test loading/saving the cache.
*