lamoda/cleaner

Library for clean old data from different storages

0.1 2019-02-11 17:13 UTC

README

Library that provides classes to clear old data from different storages, firstly from databases.

Installation

  1. Install library with composer:
composer require lamoda/cleaner

Standalone usage

Example of DoctrineDBALCleaner usage, which relies on doctrine/dbal connection.

use Lamoda\Cleaner\DB\Config\DBCleanerConfigFactory;
use Lamoda\Cleaner\DB\DoctrineDBALCleaner;

$config = DBCleanerConfigFactory::create([
    'query' => "DELETE * FROM big_table WHERE created_at < NOW() - (:interval || ' days')::interval",
    'parameters' => [
        'interval' => 90,
    ],
]);

/** @var \Doctrine\DBAL\Connection $connection */
$connection = $entityManager->getConnection();

$cleaner = new DoctrineDBALCleaner($connection, $config);
$cleaner->clear();