Add delete method on databox repositories to invalidate cache on delete

This commit is contained in:
Thibaud Fabre
2016-01-28 16:09:37 +01:00
parent 40ff41501c
commit 841182eca4
5 changed files with 29 additions and 0 deletions

View File

@@ -62,6 +62,16 @@ class ArrayCacheDataboxRepository implements DataboxRepository
return $this->repository->save($databox); return $this->repository->save($databox);
} }
/**
* @param \databox $databox
*/
public function delete(\databox $databox)
{
$this->clear();
return $this->repository->delete($databox);
}
/** /**
* @param $host * @param $host
* @param $port * @param $port

View File

@@ -69,6 +69,13 @@ final class CachingDataboxRepositoryDecorator implements DataboxRepository
return $this->repository->save($databox); return $this->repository->save($databox);
} }
public function delete(\databox $databox)
{
$this->clearCache();
return $this->repository->delete($databox);
}
/** /**
* @param $host * @param $host
* @param $port * @param $port

View File

@@ -27,6 +27,11 @@ interface DataboxRepository
*/ */
public function save(\databox $databox); public function save(\databox $databox);
/**
* @param \databox $databox
*/
public function delete(\databox $databox);
/** /**
* @param $host * @param $host
* @param $port * @param $port

View File

@@ -56,6 +56,11 @@ final class DbalDataboxRepository implements DataboxRepository
return true; return true;
} }
public function delete(\databox $databox)
{
return true;
}
/** /**
* @param int $id * @param int $id
* @return false|array * @return false|array

View File

@@ -935,6 +935,8 @@ class databox extends base implements ThumbnailedElement
$this->get_appbox()->delete_data_from_cache(appbox::CACHE_LIST_BASES); $this->get_appbox()->delete_data_from_cache(appbox::CACHE_LIST_BASES);
$this->databoxRepository->delete($this);
$this->app['dispatcher']->dispatch( $this->app['dispatcher']->dispatch(
DataboxEvents::DELETED, DataboxEvents::DELETED,
new DeletedEvent( new DeletedEvent(