-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve cache warmup by creating required directories
Calling the mapper warmup will now go through all caches layers and run a warmup process. When using `FileSystemCache` that is provided by the library, the directories required by this cache will be created. This should fix an issue that could occur when race conditions happened in an app with a lot of traffic.
- Loading branch information
Showing
13 changed files
with
242 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace CuyZ\Valinor\Cache; | ||
|
||
use Psr\SimpleCache\CacheInterface; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @template T | ||
* @extends CacheInterface<T> | ||
*/ | ||
interface WarmupCache extends CacheInterface | ||
{ | ||
public function warmup(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CuyZ\Valinor\Tests\Fake\Cache; | ||
|
||
use CuyZ\Valinor\Cache\WarmupCache; | ||
|
||
/** | ||
* @implements WarmupCache<mixed> | ||
*/ | ||
final class FakeCacheWithWarmup implements WarmupCache | ||
{ | ||
private int $warmupCount = 0; | ||
|
||
public function timesWarmupWasCalled(): int | ||
{ | ||
return $this->warmupCount; | ||
} | ||
|
||
public function warmup(): void | ||
{ | ||
$this->warmupCount++; | ||
} | ||
|
||
public function get($key, $default = null): mixed | ||
{ | ||
return null; | ||
} | ||
|
||
public function set($key, $value, $ttl = null): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function delete($key): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function clear(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function getMultiple($keys, $default = null): iterable | ||
{ | ||
return []; | ||
} | ||
|
||
public function setMultiple($values, $ttl = null): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function deleteMultiple($keys): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function has($key): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.