Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature Request: Prune caches probabilistically at the end of requests #62277

Open
@jack-worman

Description

@jack-worman

Description

I want a subscriber added to the framework bundle that will sometimes prune caches at the end of a request.

You should be able to configure the PROBABILITY_NUMERATOR and PROBABILITY_DENOMINATOR exactly like the session.gc ini settings.

Example

class PruneCachesSubscriberimplements EventSubscriberInterface{privateconstintPROBABILITY_NUMERATOR =1;privateconstintPROBABILITY_DENOMINATOR =10_000;publicfunction__construct(/** @var iterable<PruneableInterface> */privatereadonlyiterable$prunableCaches,    ) {    }publicstaticfunctiongetSubscribedEvents():array    {return [            TerminateEvent::class =>'pruneCaches',            ConsoleTerminateEvent::class =>'pruneCaches',        ];    }publicfunctionpruneCaches():void    {if (\random_int(1,self::PROBABILITY_DENOMINATOR) >self::PROBABILITY_NUMERATOR) {return;        }foreach ($this->prunableCachesas$prunableCache) {$prunableCache->prune();        }    }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp