{"id":364749,"date":"2024-05-21T02:23:36","date_gmt":"2024-05-21T02:23:36","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364749"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364749","title":{"rendered":"<span>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Symfony \/ PHP (II)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u042f, \u0410\u043d\u0434\u0440\u0435\u0439, Symfony \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a &#8212; \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0430\u0439\u0442\u044b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043c\u044b \u0442\u0440\u0430\u0442\u0438\u043c \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Symfony \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 <em>Doctrine<\/em>. \u041f\u043e\u0435\u0445\u0430\u043b\u0438<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/784660\/\" rel=\"noopener noreferrer nofollow\"><u>\u0427\u0430\u0441\u0442\u044c I<\/u><\/a><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <em>Doctrine ORM<\/em> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0430\u0432\u0434\u0430, \u043a\u0430\u043a \u0438 \u0432\u0441\u0451, \u043c\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>setter\/getter<\/code> \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0438 <code>View<\/code>, \u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u0441\u0430\u043c\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445 <em>(Entity)<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>User<\/code><em> <\/em>\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  class User implements UserInterface {    private string|null $firstName;    private string|null $lastName;    private \\DateTimeImmutable $updatedDatetime;       public function updateSettings(UserSettingsDto $data): void    {        $this->firstName = $data->firstName;        $this->lastName = $data->lastName;        $this->updatedDatetime = new \\DateTimeImmutable();    } } <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u0438\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e \u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0441 \u0431\u0430\u043b\u0430\u043d\u0441\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  class User implements UserInterface {     public function withdraw(int $amount, TransactionCategory $category, array $data = []): UserTransaction     {        if ($amount &lt; 0) {            throw new \\TypeError(\\sprintf('Passed amount should be greater than zero, %d passed.', $amount));        }                if ($this->balance - $amount &lt; 0) {             throw BillingException::createNotEnoughBalanceException($this, $amount, $category);        }                $this->transactions->add($transaction = new UserTransaction($this, -$amount, $category, $data));        $this->balance -= $amount;                return $transaction;     } } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0438\u0438 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. <\/p>\n<h2>Entity \/ \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0440\u0435\u0439\u0442\u044b<\/h2>\n<p>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u043c\u044b \u0432\u044b\u043d\u0435\u0441\u043b\u0438 \u0432 \u0442\u0440\u0435\u0439\u0442\u044b. \u042d\u0442\u043e \u043d\u0435\u0441\u0438\u043b\u044c\u043d\u043e, \u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  use Doctrine\\ORM\\Mapping as ORM; use Symfony\\Bridge\\Doctrine\\IdGenerator\\UuidGenerator; use Symfony\\Component\\Uid\\Uuid;  trait GeneratedIdTrait {     #[ORM\\Id]     #[ORM\\GeneratedValue(strategy: 'CUSTOM')]     #[ORM\\CustomIdGenerator(class: UuidGenerator::class)]     #[ORM\\Column(type: UuidType::NAME, unique: true, nullable: false)]     protected Uuid|null $id;      public function getId(): Uuid     {         return $this->id;     } } <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430, \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>AUTO INCREMENT<\/code> \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>UUID<\/code>.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c. <\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  use Doctrine\\ORM\\Mapping as ORM;  trait TimestampCreateTrait {     #[ORM\\Column(type: 'datetime_immutable', nullable: false)]     protected \\DateTimeImmutable $createdDatetime;      public function getCreatedDatetime(): \\DateTimeImmutable     {         return $this->createdDatetime;     } }<\/code><\/pre>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u0431\u043e\u0440 \u0442\u0440\u0435\u0439\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u043c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0440\u0435\u0439\u0442\u044b \u044d\u0442\u043e:<\/p>\n<ul>\n<li>\n<p><code>GeneratedIdTrait<\/code><\/p>\n<\/li>\n<li>\n<p><code>TimestampCreateTrait<\/code><\/p>\n<\/li>\n<li>\n<p><code>TimestampUpdateTrait<\/code><\/p>\n<\/li>\n<li>\n<p><code>MetaTrait<\/code> &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b &#8212; <em>title, keywords, description, robots behaviour, seo description.<\/em><\/p>\n<\/li>\n<li>\n<p><code>SlugTrait<\/code> &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u043a\u0438 <em>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b<\/em> \u0438 <em>\u0427\u041f\u0423.<\/em><\/p>\n<\/li>\n<li>\n<p><code>VersionTrait<\/code> &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0441\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <em>Doctrine. <\/em><br \/><a href=\"https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.17\/reference\/transactions-and-concurrency.html#optimistic-locking\" rel=\"noopener noreferrer nofollow\">https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.17\/reference\/transactions-and-concurrency.html#optimistic-locking<\/a><\/p>\n<\/li>\n<\/ul>\n<h2>Entity \/ ChangeTrackingPolicy<\/h2>\n<p>\u0414\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f <code>ChangeTrackingPolicy<\/code>. <\/p>\n<p><a href=\"https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.16\/reference\/change-tracking-policies.html\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.16\/reference\/change-tracking-policies.html<\/u><\/a><\/p>\n<p>\u041f\u0440\u0430\u0432\u0434\u0430, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 Doctrine, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u0435\u0451 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 <code>Doctrine\\ORM\\EntityManager::persist()<\/code><\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  #[ORM\\ChangeTrackingPolicy(value: \u2018DEFERRED_EXPLICIT')] class User {   \/** . *\/ }<\/code><\/pre>\n<pre><code class=\"php\">&lt;?php \/** In any service *\/     private function update(User $user, UserSettingsDto $data): void    {       $user->updateSettings($data);       $this->em->persist($user); # it\u2019s obligated       $this->em->flush();    }<\/code><\/pre>\n<h2>Entity \/ readonly<\/h2>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043c\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>readonly<\/code> \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <em>Doctrine<\/em> \u043d\u0435 \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0442\u0430\u043a\u0438\u043c\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0441\u043e\u0432\u0441\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  #[ORM\\Entity(repositoryClass: PushMessageSendRepository::class, readOnly: true)] #[ORM\\ChangeTrackingPolicy(value: 'DEFERRED_EXPLICIT')] class PushMessageSend {   \/** . *\/ }<\/code><\/pre>\n<h2>Entity \/ ServiceEntityRepository <\/h2>\n<p>\u0412\u0441\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043a\u043b\u0430\u0441\u0441. \u041c\u044b \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435<em> shortcut<\/em><code>findBy<\/code><em>,<\/em> \u044d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439 <code>ServiceEntityRepository<\/code> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>\\Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository<\/code>. \u041c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438.\u00a0\u041f\u0440\u0430\u0432\u0434\u0430, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0443\u044e \u0437\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439: <code>doctrine.orm.default_repository_class: Your\\Class\\Name<\/code><\/p>\n<p><a href=\"https:\/\/symfony.com\/doc\/current\/doctrine.html#querying-for-objects-the-repository\" rel=\"noopener noreferrer nofollow\">https:\/\/symfony.com\/doc\/current\/doctrine.html#querying-for-objects-the-repository<\/a><\/p>\n<h2>Doctrine \/ \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u044d\u0448\u0438<\/h2>\n<p>\u0414\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 <em>Doctrine <\/em>\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u044d\u0448\u0438.<br \/>\u041c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <em>(metadata cache)<\/em> \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0442 <code>QueryBuilder<\/code><em> (query cache)<\/em>, \u043a\u0430\u043a \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f, \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0432 <em>APCu <\/em>\u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430. <\/p>\n<p>\u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 <em>(result cache)<\/em> \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0435\u043a\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u0442.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u0440\u0435\u0434\u043a\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u043b\u0438\u0437\u0430, \u0432\u0441\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u044b \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u043b\u0433\u0438\u0439 \u0441\u0440\u043e\u043a \u0436\u0438\u0437\u043d\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0422\u0430\u043a\u0436\u0435, \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043b\u0438\u0437\u0435 \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u043a\u044d\u0448\u0438. \u041d\u0438\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"yaml\">framework:     cache:         pools:             doctrine.system_cache_pool:                 adapter: cache.adapter.apcu                 default_lifetime: 86400 doctrine:     orm:         metadata_cache_driver:             type: pool             pool: doctrine.system_cache_pool         query_cache_driver:             type: pool             pool: doctrine.system_cache_pool<\/code><\/pre>\n<h2>Doctrine \/ \u043a\u044d\u0448 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f (SLC)<\/h2>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u044d\u0448\u0435\u0439, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u044d\u0448 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u2014 <em>Second Level Cache<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u043e \u0435\u0441\u0442\u044c, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u044d\u0448\u0435, \u0438 \u043f\u0440\u0438 \u0438\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043c\u0435\u0449\u0451\u043d \u0432 \u043a\u044d\u0448.<\/p>\n<p><a href=\"https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.16\/reference\/second-level-cache.html\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.16\/reference\/second-level-cache.html<\/u><\/a> <\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043d\u0430 \u0441\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0433\u0438\u0434\u0440\u0430\u0442\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 (\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u043f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430).<\/p>\n<p><em>SLC <\/em>\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0434\u043b\u044f \u0441\u0430\u043c\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439. \u042d\u0442\u043e \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.\u00a0<\/p>\n<p>\u041a\u044d\u0448 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u0421\u0440\u0430\u0437\u0443 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041c\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u0443 \u0436\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>cache.app<\/code>, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <em>Redis.<\/em> <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u044d\u0448\u0430 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u0430 \u043a\u0430\u043a \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u044d\u0442\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c. \u041c\u044b \u043d\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c\u0441\u044f \u043d\u0430 <em>SLC <\/em>\u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0437\u0430 \u0433\u043e\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u0432\u044b\u044f\u0432\u0438\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432.<\/p>\n<p>\u041d\u0438\u0436\u0435, \u044f \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e \u0441\u0440\u043e\u043a\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445: <\/p>\n<pre><code class=\"yaml\">doctrine:     orm:         second_level_cache:             enabled: true # enables SLC             region_cache_driver: # overrides the default cache region                 type: pool                 pool: doctrine.result_cache_pool             region_lock_lifetime: 10 # in seconds             region_lifetime: 7200 # in seconds             log_enabled: true # for prod log_enabled=false<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u044d\u0448\u0435. \u041e\u0431\u043b\u0430\u0441\u0442\u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"yaml\">doctrine:     orm:         second_level_cache:             regions:                 user_region:                     lifetime: 3600                     cache_driver:                         type: service                         id: doctrine.result_cache_provider                 messages_region:                     lifetime: 600                     cache_driver:                         type: service                         id: doctrine.result_cache_provider<\/code><\/pre>\n<h3>\u0420\u0435\u0436\u0438\u043c\u044b SLC<\/h3>\n<p>\u0423 <em>SLC <\/em>\u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<ul>\n<li>\n<p><code>READ_ONLY<\/code><strong><br \/><\/strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0435\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439. \u042d\u0442\u043e \u0442\u0435 \u0436\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u043a\u0430\u043a <code>readonly<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>NONSTRICTED_READ_WRITE<\/code>\u00a0<br \/>\u0420\u0435\u0436\u0438\u043c \u0434\u043b\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435 \u0447\u0430\u0441\u0442\u043e \u0438 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0436\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p><code>READ_WRITE<\/code>\u00a0<br \/>\u0420\u0435\u0436\u0438\u043c \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>read\/write<\/em> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u0441\u0442\u0430\u0432\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u0440\u043e\u0441\u0442\u044b \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e\u043c\u0438\u043c\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  #[ORM\\Entity(repositoryClass: PushMessageSendRepository::class, readOnly: true)] #[ORM\\Cache(usage: 'READ_ONLY', region: 'messages_region')] #[ORM\\ChangeTrackingPolicy(value: 'DEFERRED_EXPLICIT')] class PushMessageSend {     \/** . *\/ } <\/code><\/pre>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  class User {     \/** . *\/     #[ORM\\OneToMany(mappedBy: \"user\", targetEntity: Video::class)]     #[ORM\\Cache(usage: 'NONSTRICT_READ_WRITE')]     #[ORM\\OrderBy(['createdDatetime' => 'ASC'])]     private iterable $videos = []; }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 <code>READ_WRITE<\/code> <em>Doctrine <\/em>\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0432\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u044d\u0448\u0435 <code>Doctrine\\ORM\\Cache\\Region\\FileLockRegion<\/code><em>. <\/em>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430, \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0433\u0438\u043e\u043d \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445: <\/p>\n<pre><code class=\"yaml\">doctrine:     orm:         second_level_cache:             regions:                 fast:                     cache_driver:                         type: service                         id: doctrine.result_cache_provider                     lock_path: \u2018%kernel.cache_dir%\/doctrine\/orm\/slc\/fast.filelock' \/\/ path to store files for locking                     lock_lifetime: 10                     type: filelock <\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u0432\u043e\u0439 \u0440\u0435\u0433\u0438\u043e\u043d \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430, \u0442\u043e \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  class User {     \/** . *\/     #[ORM\\OneToMany(mappedBy: \"user\", targetEntity: Video::class)]     #[ORM\\Cache(usage: 'READ_WRITE', region: 'fast')]     #[ORM\\OrderBy(['createdDatetime' => 'ASC'])]     private iterable $videos = []; }<\/code><\/pre>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>SLC <\/em>\u043e\u0449\u0443\u0442\u0438\u043c\u043e<em> <\/em>\u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043f\u0438\u0441\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041d\u043e, \u043a\u0430\u043a \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u0430 \u043a\u0430\u043a \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0432\u0435\u0434\u0451\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c <em>SLC<\/em> \u0432 <em>dev<\/em> \u0441\u0440\u0435\u0434\u0435.<\/p>\n<hr\/>\n<p><em>Doctrine <\/em>&#8212; \u044d\u0442\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u043d\u043e\u0433\u043e\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c &#8212; \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 DQL, \u0438 \u0442.\u0434., \u0442\u0430\u043a \u043a\u0430\u043a, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u044d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<hr\/>\n<p>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.17\/reference\/best-practices.html\" rel=\"noopener noreferrer nofollow\">https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.17\/reference\/best-practices.html<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/ocramius.github.io\/doctrine-best-practices\/#\/\" rel=\"noopener noreferrer nofollow\">https:\/\/ocramius.github.io\/doctrine-best-practices\/#\/<\/a><\/p>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/784660\/\" rel=\"noopener noreferrer nofollow\"><u>\u0427\u0430\u0441\u0442\u044c I<\/u><\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/785008\/\"> https:\/\/habr.com\/ru\/articles\/785008\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u042f, \u0410\u043d\u0434\u0440\u0435\u0439, Symfony \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a &#8212; \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0430\u0439\u0442\u044b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043c\u044b \u0442\u0440\u0430\u0442\u0438\u043c \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Symfony \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 <em>Doctrine<\/em>. \u041f\u043e\u0435\u0445\u0430\u043b\u0438<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/784660\/\" rel=\"noopener noreferrer nofollow\"><u>\u0427\u0430\u0441\u0442\u044c I<\/u><\/a><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <em>Doctrine ORM<\/em> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0430\u0432\u0434\u0430, \u043a\u0430\u043a \u0438 \u0432\u0441\u0451, \u043c\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>setter\/getter<\/code> \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0438 <code>View<\/code>, \u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 \u0441\u0430\u043c\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445 <em>(Entity)<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>User<\/code><em> <\/em>\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  class User implements UserInterface {    private string|null $firstName;    private string|null $lastName;    private \\DateTimeImmutable $updatedDatetime;       public function updateSettings(UserSettingsDto $data): void    {        $this->firstName = $data->firstName;        $this->lastName = $data->lastName;        $this->updatedDatetime = new \\DateTimeImmutable();    } } <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u0438\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e \u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0441 \u0431\u0430\u043b\u0430\u043d\u0441\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  class User implements UserInterface {     public function withdraw(int $amount, TransactionCategory $category, array $data = []): UserTransaction     {        if ($amount &lt; 0) {            throw new \\TypeError(\\sprintf('Passed amount should be greater than zero, %d passed.', $amount));        }                if ($this->balance - $amount &lt; 0) {             throw BillingException::createNotEnoughBalanceException($this, $amount, $category);        }                $this->transactions->add($transaction = new UserTransaction($this, -$amount, $category, $data));        $this->balance -= $amount;                return $transaction;     } } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0438\u0438 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. <\/p>\n<h2>Entity \/ \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0440\u0435\u0439\u0442\u044b<\/h2>\n<p>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u043c\u044b \u0432\u044b\u043d\u0435\u0441\u043b\u0438 \u0432 \u0442\u0440\u0435\u0439\u0442\u044b. \u042d\u0442\u043e \u043d\u0435\u0441\u0438\u043b\u044c\u043d\u043e, \u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  use Doctrine\\ORM\\Mapping as ORM; use Symfony\\Bridge\\Doctrine\\IdGenerator\\UuidGenerator; use Symfony\\Component\\Uid\\Uuid;  trait GeneratedIdTrait {     #[ORM\\Id]     #[ORM\\GeneratedValue(strategy: 'CUSTOM')]     #[ORM\\CustomIdGenerator(class: UuidGenerator::class)]     #[ORM\\Column(type: UuidType::NAME, unique: true, nullable: false)]     protected Uuid|null $id;      public function getId(): Uuid     {         return $this->id;     } } <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430, \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>AUTO INCREMENT<\/code> \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>UUID<\/code>.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c. <\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  use Doctrine\\ORM\\Mapping as ORM;  trait TimestampCreateTrait {     #[ORM\\Column(type: 'datetime_immutable', nullable: false)]     protected \\DateTimeImmutable $createdDatetime;      public function getCreatedDatetime(): \\DateTimeImmutable     {         return $this->createdDatetime;     } }<\/code><\/pre>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u0431\u043e\u0440 \u0442\u0440\u0435\u0439\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u043c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0440\u0435\u0439\u0442\u044b \u044d\u0442\u043e:<\/p>\n<ul>\n<li>\n<p><code>GeneratedIdTrait<\/code><\/p>\n<\/li>\n<li>\n<p><code>TimestampCreateTrait<\/code><\/p>\n<\/li>\n<li>\n<p><code>TimestampUpdateTrait<\/code><\/p>\n<\/li>\n<li>\n<p><code>MetaTrait<\/code> &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b &#8212; <em>title, keywords, description, robots behaviour, seo description.<\/em><\/p>\n<\/li>\n<li>\n<p><code>SlugTrait<\/code> &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u043a\u0438 <em>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b<\/em> \u0438 <em>\u0427\u041f\u0423.<\/em><\/p>\n<\/li>\n<li>\n<p><code>VersionTrait<\/code> &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0441\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <em>Doctrine. <\/em><br \/><a href=\"https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.17\/reference\/transactions-and-concurrency.html#optimistic-locking\" rel=\"noopener noreferrer nofollow\">https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.17\/reference\/transactions-and-concurrency.html#optimistic-locking<\/a><\/p>\n<\/li>\n<\/ul>\n<h2>Entity \/ ChangeTrackingPolicy<\/h2>\n<p>\u0414\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f <code>ChangeTrackingPolicy<\/code>. <\/p>\n<p><a href=\"https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.16\/reference\/change-tracking-policies.html\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.16\/reference\/change-tracking-policies.html<\/u><\/a><\/p>\n<p>\u041f\u0440\u0430\u0432\u0434\u0430, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 Doctrine, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u0435\u0451 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 <code>Doctrine\\ORM\\EntityManager::persist()<\/code><\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  #[ORM\\ChangeTrackingPolicy(value: \u2018DEFERRED_EXPLICIT')] class User {   \/** . *\/ }<\/code><\/pre>\n<pre><code class=\"php\">&lt;?php \/** In any service *\/     private function update(User $user, UserSettingsDto $data): void    {       $user->updateSettings($data);       $this->em->persist($user); # it\u2019s obligated       $this->em->flush();    }<\/code><\/pre>\n<h2>Entity \/ readonly<\/h2>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043c\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>readonly<\/code> \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <em>Doctrine<\/em> \u043d\u0435 \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0442\u0430\u043a\u0438\u043c\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0441\u043e\u0432\u0441\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  #[ORM\\Entity(repositoryClass: PushMessageSendRepository::class, readOnly: true)] #[ORM\\ChangeTrackingPolicy(value: 'DEFERRED_EXPLICIT')] class PushMessageSend {   \/** . *\/ }<\/code><\/pre>\n<h2>Entity \/ ServiceEntityRepository <\/h2>\n<p>\u0412\u0441\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043a\u043b\u0430\u0441\u0441. \u041c\u044b \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435<em> shortcut<\/em><code>findBy<\/code><em>,<\/em> \u044d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439 <code>ServiceEntityRepository<\/code> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>\\Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository<\/code>. \u041c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438.\u00a0\u041f\u0440\u0430\u0432\u0434\u0430, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0443\u044e \u0437\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439: <code>doctrine.orm.default_repository_class: Your\\Class\\Name<\/code><\/p>\n<p><a href=\"https:\/\/symfony.com\/doc\/current\/doctrine.html#querying-for-objects-the-repository\" rel=\"noopener noreferrer nofollow\">https:\/\/symfony.com\/doc\/current\/doctrine.html#querying-for-objects-the-repository<\/a><\/p>\n<h2>Doctrine \/ \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u044d\u0448\u0438<\/h2>\n<p>\u0414\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 <em>Doctrine <\/em>\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u044d\u0448\u0438.<br \/>\u041c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <em>(metadata cache)<\/em> \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0442 <code>QueryBuilder<\/code><em> (query cache)<\/em>, \u043a\u0430\u043a \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f, \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0432 <em>APCu <\/em>\u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430. <\/p>\n<p>\u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 <em>(result cache)<\/em> \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0435\u043a\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u0442.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u0440\u0435\u0434\u043a\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u043b\u0438\u0437\u0430, \u0432\u0441\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u044b \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u043b\u0433\u0438\u0439 \u0441\u0440\u043e\u043a \u0436\u0438\u0437\u043d\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0422\u0430\u043a\u0436\u0435, \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043b\u0438\u0437\u0435 \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u043a\u044d\u0448\u0438. \u041d\u0438\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"yaml\">framework:     cache:         pools:             doctrine.system_cache_pool:                 adapter: cache.adapter.apcu                 default_lifetime: 86400 doctrine:     orm:         metadata_cache_driver:             type: pool             pool: doctrine.system_cache_pool         query_cache_driver:             type: pool             pool: doctrine.system_cache_pool<\/code><\/pre>\n<h2>Doctrine \/ \u043a\u044d\u0448 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f (SLC)<\/h2>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u044d\u0448\u0435\u0439, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u044d\u0448 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u2014 <em>Second Level Cache<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u043e \u0435\u0441\u0442\u044c, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u044d\u0448\u0435, \u0438 \u043f\u0440\u0438 \u0438\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043c\u0435\u0449\u0451\u043d \u0432 \u043a\u044d\u0448.<\/p>\n<p><a href=\"https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.16\/reference\/second-level-cache.html\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.doctrine-project.org\/projects\/doctrine-orm\/en\/2.16\/reference\/second-level-cache.html<\/u><\/a> <\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043d\u0430 \u0441\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0433\u0438\u0434\u0440\u0430\u0442\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 (\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u043f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430).<\/p>\n<p><em>SLC <\/em>\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0434\u043b\u044f \u0441\u0430\u043c\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439. \u042d\u0442\u043e \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.\u00a0<\/p>\n<p>\u041a\u044d\u0448 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u0421\u0440\u0430\u0437\u0443 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041c\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u0443 \u0436\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>cache.app<\/code>, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <em>Redis.<\/em> <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u044d\u0448\u0430 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u0430 \u043a\u0430\u043a \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u044d\u0442\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c. \u041c\u044b \u043d\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c\u0441\u044f \u043d\u0430 <em>SLC <\/em>\u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0437\u0430 \u0433\u043e\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u0432\u044b\u044f\u0432\u0438\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432.<\/p>\n<p>\u041d\u0438\u0436\u0435, \u044f \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e \u0441\u0440\u043e\u043a\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445: <\/p>\n<pre><code class=\"yaml\">doctrine:     orm:         second_level_cache:             enabled: true # enables SLC             region_cache_driver: # overrides the default cache region                 type: pool                 pool: doctrine.result_cache_pool             region_lock_lifetime: 10 # in seconds             region_lifetime: 7200 # in seconds             log_enabled: true # for prod log_enabled=false<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u044d\u0448\u0435. \u041e\u0431\u043b\u0430\u0441\u0442\u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"yaml\">doctrine:     orm:         second_level_cache:             regions:                 user_region:                     lifetime: 3600                     cache_driver:                         type: service                         id: doctrine.result_cache_provider                 messages_region:                     lifetime: 600                     cache_driver:                         type: service                         id: doctrine.result_cache_provider<\/code><\/pre>\n<h3>\u0420\u0435\u0436\u0438\u043c\u044b SLC<\/h3>\n<p>\u0423 <em>SLC <\/em>\u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<ul>\n<li>\n<p><code>READ_ONLY<\/code><strong><br \/><\/strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0435\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439. \u042d\u0442\u043e \u0442\u0435 \u0436\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u043a\u0430\u043a <code>readonly<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>NONSTRICTED_READ_WRITE<\/code>\u00a0<br \/>\u0420\u0435\u0436\u0438\u043c \u0434\u043b\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435 \u0447\u0430\u0441\u0442\u043e \u0438 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0436\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p><code>READ_WRITE<\/code>\u00a0<br \/>\u0420\u0435\u0436\u0438\u043c \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>read\/write<\/em> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u0441\u0442\u0430\u0432\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u0440\u043e\u0441\u0442\u044b \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e\u043c\u0438\u043c\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  #[ORM\\Entity(repositoryClass: PushMessageSendRepository::class, readOnly: true)] #[ORM\\Cache(usage: 'READ_ONLY', region: 'messages_region')] #[ORM\\ChangeTrackingPolicy(value: 'DEFERRED_EXPLICIT')] class PushMessageSend {     \/** . *\/ } <\/code><\/pre>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php \/** . *\/  class User {     \/** . *\/ <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-364749","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364749"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364749\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}