/** * Delete chunks older than expiration time. * * @param \MongoGridFS $gridFs * @param int $expirationTime seconds * * @throws FileOpenException */ public static function pruneChunks($gridFs, $expirationTime = 172800) { $result = $gridFs->remove(['flowUpdated' => ['$lt' => new \MongoDate(time() - $expirationTime)], 'flowStatus' => 'uploading']); if (!$result) { throw new FileOpenException("Could not remove chunks!"); } }
/** */ public function gc($path, $secs = 345600) { $query = array($this->_mdKey(self::PATH) => array('$regex' => '^' . $this->_convertPath($path)), 'uploadDate' => array('$lt' => new MongoDate(time() - $secs))); try { $this->_files->remove($query); } catch (MongoException $e) { throw new Horde_Vfs_Exception($e); } }
/** * remove. */ public function remove($criteria = array(), array $options = array()) { $this->time->start(); $return = parent::remove($criteria, $options); $time = $this->time->stop(); $this->log(array('type' => 'remove', 'criteria' => $criteria, 'options' => $options, 'time' => $time)); return $return; }
/** * 删除陈旧的文件 * * @param mixed $id * \MongoID or String * @return bool true or false */ public function removeFileFromGridFS($id) { if (!$id instanceof \MongoId) { $id = new \MongoId($id); } return $this->_fs->remove(array('_id' => $id)); }