承接 a4sex/auto-clean-entity 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

a4sex/auto-clean-entity

最新稳定版本:v1.0.3

Composer 安装命令:

composer require a4sex/auto-clean-entity

包简介

Abstract Doctrine Entity Cleaner

README 文档

README

Create Cleaner for specific doctrine Entity

Entity MUST contain the id primary field and some date_time field

<?php

namespace App\Services\Cleaner;

use A4Sex\Services\AbstractCleaner; 
use App\Repository\MessageRepository;

class MessageCleaner extends AbstractCleaner
{  
    public $autocleanEnable = true;
    public $cleanDaysPeriod = 7;
    public $cleanDateField = 'date';
    // OR/AND Add batch cleaner params

    public function __construct(
        DialogRepository $repository
    ) {
        $this->repository = $repository;
    }

}

Some settings

    public $autocleanEnable = false; // default - disabled
    public $autocleanEvery = 10; // conditionally, each (divisible) - 10 - every tenth
    public $cleanDaysPeriod = 15; // more than a few days old
    public $cleanItemsCount = 100; // select no more items
    public $cleanDateField = 'updated'; // `db` datetime field 

Use auto cleaning


    // ...
    public function __construct(
        MessageCleaner $cleaner
    ) {
        $this->cleaner = $cleaner;
    }

    public function someFunction()
    {
        // ...
        $id = $this->user->getId(); // Some random/pseudorandom/regular number
        $this->cleaner->autoclean($id, 'updated');
        // OR
        $this->cleaner->autoclean($id); // 'updated' is default
        // or set const `$cleanDateField`
        // $id - required
        // if $id = 10 and `$autocleanEvery` = 10 - then cleanup will be called every time
        // if $id not divisible by 10 and `$autocleanEvery` = 10 - cleanup will not be called
    }
    // ...   

Batch Cleaner

Some settings

    public bool $batchCleanVerbose = false; // verbose output
    public int $cleanBatchPart = 1000; // count deleted items on iteration
    public int $batchItemsCount = 10000; // count all selected items
    public int $batchLoopDelay = 0; // delay between iterations

    // ...
    public function someFunction()
    {
        // ...
        $this->cleaner->batchclean('updated');
        // OR
        $this->cleaner->batchclean(); // 'updated' is default
        // or set const `$cleanDateField`
    }
    // ...   

统计信息

  • 总下载量: 153
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-04