Skip to content

Commit

Permalink
fix: CacheBridgeAbstract::save() not assigning value to cache when …
Browse files Browse the repository at this point in the history
…cache hit mises (#434)

* Fixed item cache value 

Signed-off-by: Sergey Mutaf <[email protected]>

* Update tests for successful passing

---------

Signed-off-by: Sergey Mutaf <[email protected]>
Co-authored-by: Evan Sims <[email protected]>
Co-authored-by: Evan Sims <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent a53f05c commit 30aafed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Bridges/CacheBridgeAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final public function save(CacheItemInterface $item): bool
return false;
}

$value = serialize($item->get());
$value = serialize($item->getRawValue());
$key = $item->getKey();
$expires = $item->getExpiration();

Expand Down
8 changes: 3 additions & 5 deletions tests/Unit/Bridges/CacheBridgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,20 @@
expect($cache)
->toBeInstanceOf(CacheItemBridge::class)
->isHit()->toBeTrue()
->get()->toBeNull()
->set(42)
->get()->toBe(42);
->get()->toEqual(42);

$results = $pool->getItems();

expect($results)
->toBeArray()
->toHaveCount(0);

$results = $pool->getItems(['testing' => uniqid()]);
$results = $pool->getItems(['testing']);

expect($results['testing'])
->toBeInstanceOf(CacheItemBridge::class)
->isHit()->toBeTrue()
->get()->not()->toBe(42);
->get()->toEqual(42);

$this->app[\Illuminate\Cache\CacheManager::class]
->getStore()
Expand Down

0 comments on commit 30aafed

Please sign in to comment.