Skip to content

Commit

Permalink
[5.x] Allow defining a store in the cache tag (#10318)
Browse files Browse the repository at this point in the history
  • Loading branch information
riasvdv authored Jun 18, 2024
1 parent 604fff8 commit 84af7e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tags/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions tests/Tags/CacheTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 84af7e1

Please sign in to comment.