Elektrine lite

← Feed

@ramsey@phpc.social

Post #3859990

2026-07-16 13:50 UTC

@nyamsprod@phpc.social What do you mean by losing an in-memory cache of your class?

Replies (1)

  • @nyamsprod@phpc.social 2026-07-16 13:57

    @ramsey@phpc.social final class readonly Duration { public function __construct(public $microseconds) {} public static function zero(): self { static $instance = null; $instance ??= new self(0); return $instance; } } The "zero" instance is a singletion declared once and because of the readonly it is safe to use, only once instance will be created

    Open ##3859989