Skip to content

Commit ec7c78c

Browse files
authored
Asset blink should cache the asset not the model (#449)
* Remove blink cache for asset model * On second thoughts, just blink the right thing * add test coverage to prevent regression
1 parent f578871 commit ec7c78c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Assets/Asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function fromModel(Model $model)
3838
->hydrateMeta($model->meta)
3939
->syncOriginal();
4040

41-
Blink::put('eloquent-asset-'.$asset->id(), $model);
41+
Blink::put('eloquent-asset-'.$asset->id(), $asset);
4242
Blink::put($asset->metaCacheKey(), $model->meta);
4343

4444
return $asset;

tests/Assets/AssetTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Foundation\Testing\RefreshDatabase;
66
use Illuminate\Support\Facades\Storage;
77
use PHPUnit\Framework\Attributes\Test;
8+
use Statamic\Eloquent\Assets\Asset;
89
use Statamic\Facades;
910
use Tests\TestCase;
1011

@@ -47,6 +48,7 @@ public function saving_an_asset_clears_the_eloquent_blink_cache()
4748
$asset = Facades\Asset::find('test::f.jpg');
4849

4950
$this->assertTrue(Facades\Blink::has("eloquent-asset-{$asset->id()}"));
51+
$this->assertInstanceOf(Asset::class, Facades\Blink::get("eloquent-asset-{$asset->id()}"));
5052

5153
$asset->save();
5254

0 commit comments

Comments
 (0)