$this->createDriverFromParams($params),
$this
);
+ if (!empty($params['cache'])) {
+ $storage = new Horde_Kolab_Storage_Decorator_Cache(
+ $storage,
+ $this->createCache($params['cache']),
+ $this
+ );
+ }
if (!empty($params['logger'])) {
$storage = new Horde_Kolab_Storage_Decorator_Log(
$storage, $params['logger']
}
return $this->_folder_types[$annotation];
}
+
+ /**
+ * Create the cache handler.
+ *
+ * @param mixed $params The cache configuration or a Horde cache object
+ *
+ * @return Horde_Kolab_Storage_Cache The cache handler.
+ */
+ public function createCache($params)
+ {
+ if ($params instanceOf Horde_Cache) {
+ return new Horde_Kolab_Storage_Cache($params);
+ } else {
+ $cache = new Horde_Cache(
+ new Horde_Cache_Storage_File(
+ $params
+ ),
+ array('lifetime' => 0)
+ );
+ }
+ return new Horde_Kolab_Storage_Cache(
+ $cache
+ );
+ }
}
\ No newline at end of file
);
}
+ public function testCacheDecoration()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $this->assertInstanceOf(
+ 'Horde_Kolab_Storage_Decorator_Cache',
+ $factory->createFromParams(
+ array(
+ 'driver' => 'mock',
+ 'cache' => array('')
+ )
+ )
+ );
+ }
+
public function testTimerDecoration()
{
$factory = new Horde_Kolab_Storage_Factory();
)
);
}
+
+ public function testCacheInstance()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $cache = new Horde_Cache(new Horde_Cache_Storage_Mock());
+ $this->assertInstanceOf(
+ 'Horde_Kolab_Storage_Cache', $factory->createCache($cache)
+ );
+ }
+
+ public function testCacheFilebased()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $this->assertInstanceOf(
+ 'Horde_Kolab_Storage_Cache', $factory->createCache(array())
+ );
+ }
}