From 84af7e16d4ec0ce5d76cd215a8602982fdac2b02 Mon Sep 17 00:00:00 2001 From: Rias Date: Tue, 18 Jun 2024 15:47:01 +0200 Subject: [PATCH] [5.x] Allow defining a store in the cache tag (#10318) --- src/Tags/Cache.php | 2 +- tests/Tags/CacheTagTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Tags/Cache.php b/src/Tags/Cache.php index 9a432e91d7..c1076bba57 100644 --- a/src/Tags/Cache.php +++ b/src/Tags/Cache.php @@ -17,7 +17,7 @@ public function index() return []; } - $store = LaraCache::store(); + $store = LaraCache::store($this->params->get('store')); if (count($tags = $this->params->explode('tags', []))) { $store = $store->tags($tags); diff --git a/tests/Tags/CacheTagTest.php b/tests/Tags/CacheTagTest.php index 9bbae17069..ab9f1ab60d 100644 --- a/tests/Tags/CacheTagTest.php +++ b/tests/Tags/CacheTagTest.php @@ -34,6 +34,20 @@ public function it_caches_its_contents_the_first_time() $this->assertMissed(); } + /** @test */ + public function it_can_use_a_custom_cache_store() + { + config()->set('cache.stores.statamic', ['driver' => 'array']); + + $template = '{{ cache store="statamic" }}expensive{{ /cache }}'; + + Event::fake(); + + $this->assertEquals('expensive', $this->tag($template)); + + $this->assertMissed(); + } + /** @test */ public function it_skips_the_cache_if_cache_tags_are_not_enabled() {