-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
342 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SpomkyLabs\PwaBundle\Service; | ||
|
||
final readonly class CacheStrategy | ||
{ | ||
public const STRATEGY_CACHE_FIRST = 'cacheFirst'; | ||
|
||
public const STRATEGY_CACHE_ONLY = 'cacheOnly'; | ||
|
||
public const STRATEGY_NETWORK_FIRST = 'networkFirst'; | ||
|
||
public const STRATEGY_NETWORK_ONLY = 'networkOnly'; | ||
|
||
public const STRATEGY_STALE_WHILE_REVALIDATE = 'staleWhileRevalidate'; | ||
|
||
public const STRATEGIES = [ | ||
self::STRATEGY_CACHE_FIRST, | ||
self::STRATEGY_CACHE_ONLY, | ||
self::STRATEGY_NETWORK_FIRST, | ||
self::STRATEGY_NETWORK_ONLY, | ||
self::STRATEGY_STALE_WHILE_REVALIDATE, | ||
]; | ||
|
||
public function __construct( | ||
public string $name, | ||
public string $strategy, | ||
public string $urlPattern, | ||
public bool $enabled, | ||
public bool $requireWorkbox, | ||
/** | ||
* @var array{maxTimeout?: int, maxAge?: int, maxEntries?: int} | ||
*/ | ||
public array $options = [] | ||
) { | ||
} | ||
|
||
/** | ||
* @param array{maxTimeout?: int, maxAge?: int, maxEntries?: int} $options | ||
*/ | ||
public static function create( | ||
string $name, | ||
string $strategy, | ||
string $urlPattern, | ||
bool $enabled, | ||
bool $requireWorkbox, | ||
array $options = [] | ||
): self { | ||
return new self($name, $strategy, $urlPattern, $enabled, $requireWorkbox, $options); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SpomkyLabs\PwaBundle\Service; | ||
|
||
interface HasCacheStrategies | ||
{ | ||
/** | ||
* @return array<CacheStrategy> | ||
*/ | ||
public function getCacheStrategies(): array; | ||
} |
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
Oops, something went wrong.