[BUGFIX] Fix delete query in getAndRemovePathsInCacheQueue method.

The redundant comma at the end of the paths list in delete query's
where clause caused the query to fail. This has been fixed.

The method as well as the class had some place for re-factoring.
This has also been carried out with the bug-fix.

Change-Id: Ic7722a6c52d71a213a9f9e5e114443c63590d68a
Reviewed-on: https://review.typo3.org/29506
Reviewed-by: Christian Zenker
Tested-by: Christian Zenker