introducing automatic purging of expired pastes, triggered by default at least 5 minutes apart, deleting a maximum of 10 pastes - resolves #3

This commit is contained in:
El RIDO
2016-07-15 17:02:59 +02:00
parent 4d10fd9690
commit f8bc40b4e4
13 changed files with 404 additions and 12 deletions

View File

@@ -123,6 +123,35 @@ abstract class privatebin_abstract
*/
abstract public function existsComment($pasteid, $parentid, $commentid);
/**
* Returns up to batch size number of paste ids that have expired
*
* @access protected
* @param int $batchsize
* @return array
*/
abstract protected function _getExpiredPastes($batchsize);
/**
* Perform a purge of old pastes, at most the given batchsize is deleted.
*
* @access public
* @param int $batchsize
* @return void
*/
public function purge($batchsize)
{
if ($batchsize < 1) return;
$pastes = $this->_getExpiredPastes($batchsize);
if (count($pastes))
{
foreach ($pastes as $pasteid)
{
$this->delete($pasteid);
}
}
}
/**
* Get next free slot for comment from postdate.
*