/**
  * remove deleted objects from cache
  */
 public function clean()
 {
     try {
         $objectAPI = $this->calendar->getBackend()->getObjectAPI($this->calendar);
         $list = $objectAPI->listAll();
     } catch (BackendUtils\Exception $ex) {
         return;
     }
     $cList = $this->cache->listAll();
     $deletedOnRemote = array_diff($cList, $list);
     $this->cache->deleteList($deletedOnRemote);
 }
 /**
  * Find a certain object
  *
  * @param string $uri UID of the object
  * @param integer $type
  * @throws \OCA\Calendar\BusinessLayer\Exception
  * @return \OCA\Calendar\IObject
  */
 public function find($uri, $type = ObjectType::ALL)
 {
     try {
         if ($this->isCachingEnabled) {
             if ($this->watcher->checkUpdate($uri)) {
                 $this->updater->propagate($uri);
             }
             return $this->cache->find($uri, $type);
         } else {
             return $this->api->find($uri, $type);
         }
     } catch (BackendUtils\Exception $ex) {
         throw Exception::fromException($ex);
     }
 }
 /**
  * scan calendar for changed objects
  */
 public function scan()
 {
     if (!$this->isCalendarsBackendValid()) {
         return;
     }
     $cachedList = $this->cache->listAll();
     try {
         $remoteList = $this->objectAPI->listAll();
     } catch (BackendUtils\Exception $ex) {
         return;
     }
     $list = array_merge($cachedList, $remoteList);
     foreach ($list as $l) {
         $this->scanObject($l);
     }
 }