From 69d59e874022a5b2183fc215e097db8be8a041a6 Mon Sep 17 00:00:00 2001 From: shinsenter <2082119+shinsenter@users.noreply.github.com> Date: Thu, 2 Apr 2020 16:33:25 +0900 Subject: [PATCH] Do not cache when using the write pdo for query --- src/Query/Builder.php | 14 ++++++++++++++ src/Traits/QueryCacheable.php | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/Query/Builder.php b/src/Query/Builder.php index 6e85241..eeb512e 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -21,4 +21,18 @@ public function get($columns = ['*']) return parent::get($columns); } + + /** + * {@inheritdoc} + */ + public function useWritePdo() + { + // Do not cache when using the write pdo for query. + $this->dontCache(); + + // Call parent method + parent::useWritePdo(); + + return $this; + } } diff --git a/src/Traits/QueryCacheable.php b/src/Traits/QueryCacheable.php index f37b5be..2ef4fdd 100644 --- a/src/Traits/QueryCacheable.php +++ b/src/Traits/QueryCacheable.php @@ -21,6 +21,8 @@ protected function newBaseQueryBuilder() if ($this->cacheFor) { $builder->cacheFor($this->cacheFor); + } else { + $builder->dontCache(); } if ($this->cacheTags) {