From 6135bb4b2eb33b70910592ee3ab5c3cea7d36790 Mon Sep 17 00:00:00 2001 From: AlexProfanov Date: Thu, 7 Jun 2018 18:13:43 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D1=8B=20=D0=B4=D0=B5=D0=BC=D0=BE=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- daemon/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/Dockerfile b/daemon/Dockerfile index 18e69a8..0fbe116 100644 --- a/daemon/Dockerfile +++ b/daemon/Dockerfile @@ -1,4 +1,4 @@ -FROM cache_practices_daemon:latest +FROM timurns/cache_practices_daemon:latest ENV DIR="/var/daemon" \ MYSQL_HOST="mysql" \ From 97b83fcd8e194f86a319902ef6f541d9865e2e18 Mon Sep 17 00:00:00 2001 From: AlexProfanov Date: Thu, 7 Jun 2018 18:16:21 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB=D1=8E=D1=87=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B4=D1=82=D1=8F=D0=B3=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86?= =?UTF-8?q?=D1=8B=20=D1=81=20=D0=BA=D0=BD=D0=B8=D0=B3=D0=B0=D0=BC=D0=B8=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8=20=D0=B8=D0=B7=D0=B4=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- daemon/dependencies.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/daemon/dependencies.json b/daemon/dependencies.json index 0146be8..116326f 100644 --- a/daemon/dependencies.json +++ b/daemon/dependencies.json @@ -14,7 +14,8 @@ "table_name": "bookstore.categories" }, { - "table_name": "bookstore.authors_books" + "table_name": "bookstore.authors_books", + "primary_key": "id_book" }, { "table_name": "bookstore.authors" @@ -43,4 +44,4 @@ } ] } -] \ No newline at end of file +] From 8d31b453e65ed26e90c980120c81c780916470cb Mon Sep 17 00:00:00 2001 From: AlexProfanov Date: Thu, 7 Jun 2018 18:19:00 +0500 Subject: [PATCH 3/3] =?UTF-8?q?=D0=A0=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EventProcessors/InsertEventProcessor.php | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/daemon/src/EventProcessors/InsertEventProcessor.php b/daemon/src/EventProcessors/InsertEventProcessor.php index 40d7f4b..9613448 100644 --- a/daemon/src/EventProcessors/InsertEventProcessor.php +++ b/daemon/src/EventProcessors/InsertEventProcessor.php @@ -6,6 +6,43 @@ class InsertEventProcessor extends BaseEventProcessor { public function process(): void { - // TODO: Implement process() method. + if (!$this->eventInfo['changedRows'] + || empty($this->eventInfo['values']) + || empty($this->eventInfo['tableMap']) + || !\count($this->eventInfo['values']) + ) { + return; + } + + /** @var TableMap $tableMap */ + $tableMap = $this->eventInfo['tableMap']; + /** @var InvalidateRule[] $rules */ + $rules = $this->getRulesFromDependencies($tableMap); + + #var_export($this->eventInfo); + #var_export($rules); + + foreach ($rules as $rule) { + $warmer = $this->getWarmerBy($rule->getHashName()); + + if ($rule->isSingleKey()) { + $warmer->fetchAllEntities(); + #$warmer->warm($warmer->getKey([]), $warmer->getEntities()); + foreach ($warmer->getEntities() as $entity) + $warmer->warm($warmer->getKey($entity), $entity); + } elseif ($rule->hasPrimaryKey()) { + foreach ($this->eventInfo['values'] as $change) { + #echo "CHANGE"; + #var_export($change); + $pk = $rule->getPrimaryKey(); + $id = $change[$pk]; + #echo "ID is " . $id; + $entity = $warmer->fetchById($id); + #var_export($entity); + if (!empty($entity)) + $warmer->warm($warmer->getKey($entity), $entity); + } + } + } } -} \ No newline at end of file +}