-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2980 from bolt/improve-caching
Improve caching
- Loading branch information
Showing
15 changed files
with
167 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Bolt\Cache; | ||
|
||
use Bolt\Canonical; | ||
|
||
class CanonicalCacher extends Canonical implements CachingInterface | ||
{ | ||
use CachingTrait; | ||
|
||
public const CACHE_CONFIG_KEY = 'canonical'; | ||
|
||
public function generateLink(?string $route, ?array $params, $canonical = false): ?string | ||
{ | ||
$this->setCacheKey([$route, $canonical] + $params); | ||
|
||
return $this->execute([parent::class, __FUNCTION__], [$route, $params, $canonical]); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Bolt\Cache; | ||
|
||
use Bolt\Entity\Content; | ||
use Bolt\Twig\JsonExtension; | ||
|
||
class ContentToArrayCacher extends JsonExtension implements CachingInterface | ||
{ | ||
use CachingTrait; | ||
|
||
public const CACHE_CONFIG_KEY = 'content_array'; | ||
|
||
protected function contentToArray(Content $content, string $locale = ''): array | ||
{ | ||
$this->setCacheKey([$content->getCacheKey($locale)]); | ||
$this->setCacheTags([$content->getCacheKey()]); | ||
|
||
return $this->execute([parent::class, __FUNCTION__], [$content, $locale]); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Bolt\Cache; | ||
|
||
use Bolt\Entity\Field; | ||
use Bolt\Twig\FieldExtension; | ||
|
||
class SelectOptionsCacher extends FieldExtension implements CachingInterface | ||
{ | ||
use CachingTrait; | ||
|
||
public const CACHE_CONFIG_KEY = 'selectoptions'; | ||
|
||
public function selectOptionsHelper(string $contentTypeSlug, array $params, Field $field, string $format): array | ||
{ | ||
$this->setCacheKey([$contentTypeSlug, $format] + $params); | ||
$this->setCacheTags([$contentTypeSlug]); | ||
|
||
return $this->execute([parent::class, __FUNCTION__], [$contentTypeSlug, $params, $field, $format]); | ||
} | ||
} |
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.