mirror of
https://github.com/getgrav/grav.git
synced 2026-07-29 01:59:02 +02:00
Added MediaTrait::getMediaCache() to allow custom caching
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* Added twig filters for casting values: `|string`, `|int`, `|bool`, `|float`, `|array`
|
||||
1. [](#improved)
|
||||
* Added `MediaTrait::clearMediaCache()` to allow cache to be cleared
|
||||
* Added `MediaTrait::getMediaCache()` to allow custom caching
|
||||
1. [](#bugfix)
|
||||
* Made `|markdown` filter HTML safe
|
||||
|
||||
|
||||
@@ -55,8 +55,7 @@ trait MediaTrait
|
||||
*/
|
||||
public function getMedia()
|
||||
{
|
||||
/** @var Cache $cache */
|
||||
$cache = Grav::instance()['cache'];
|
||||
$cache = $this->getMediaCache();
|
||||
|
||||
if ($this->media === null) {
|
||||
// Use cached media if possible.
|
||||
@@ -79,8 +78,7 @@ trait MediaTrait
|
||||
*/
|
||||
protected function setMedia(MediaCollectionInterface $media)
|
||||
{
|
||||
/** @var Cache $cache */
|
||||
$cache = Grav::instance()['cache'];
|
||||
$cache = $this->getMediaCache();
|
||||
$cacheKey = md5('media' . $this->getCacheKey());
|
||||
$cache->save($cacheKey, $media);
|
||||
|
||||
@@ -94,13 +92,19 @@ trait MediaTrait
|
||||
*/
|
||||
protected function clearMediaCache()
|
||||
{
|
||||
/** @var Cache $cache */
|
||||
$cache = Grav::instance()['cache'];
|
||||
|
||||
$cache = $this->getMediaCache();
|
||||
$cacheKey = md5('media' . $this->getCacheKey());
|
||||
$cache->delete($cacheKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cache
|
||||
*/
|
||||
protected function getMediaCache()
|
||||
{
|
||||
return Grav::instance()['cache'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user