|
4 | 4 |
|
5 | 5 | use Closure; |
6 | 6 | use Craft; |
| 7 | +use craft\cachecascade\CascadeCache; |
7 | 8 | use craft\helpers\App; |
| 9 | +use yii\caching\ArrayCache; |
8 | 10 | use yii\redis\Cache as RedisCache; |
9 | 11 |
|
10 | 12 | class AppConfig |
@@ -71,27 +73,27 @@ private function getCacheConfig(): Closure |
71 | 73 | $defaultDuration = Craft::$app->getConfig()->getGeneral()->cacheDuration; |
72 | 74 | $valkey = $this->resolveValkeyEndpoint(); |
73 | 75 |
|
74 | | - if ($valkey) { |
75 | | - return Craft::createObject([ |
76 | | - 'class' => RedisCache::class, |
77 | | - 'defaultDuration' => $defaultDuration, |
78 | | - 'redis' => [ |
79 | | - 'class' => Redis::class, |
80 | | - 'url' => $valkey, |
81 | | - 'database' => 0, |
82 | | - ], |
83 | | - ]); |
84 | | - } |
85 | | - |
86 | | - if ($this->tableExists(\craft\db\Table::CACHE)) { |
87 | | - return Craft::createObject([ |
88 | | - 'class' => \craft\cache\DbCache::class, |
89 | | - 'cacheTable' => \craft\db\Table::CACHE, |
90 | | - 'defaultDuration' => $defaultDuration, |
91 | | - ]); |
92 | | - } |
| 76 | + $primaryCache = $valkey ? [ |
| 77 | + 'class' => RedisCache::class, |
| 78 | + 'defaultDuration' => $defaultDuration, |
| 79 | + 'redis' => [ |
| 80 | + 'class' => Redis::class, |
| 81 | + 'url' => $valkey, |
| 82 | + 'database' => 0, |
| 83 | + ], |
| 84 | + ] : [ |
| 85 | + 'class' => \craft\cache\DbCache::class, |
| 86 | + 'cacheTable' => \craft\db\Table::CACHE, |
| 87 | + 'defaultDuration' => $defaultDuration, |
| 88 | + ]; |
93 | 89 |
|
94 | | - return Craft::createObject(App::cacheConfig()); |
| 90 | + return Craft::createObject([ |
| 91 | + 'class' => CascadeCache::class, |
| 92 | + 'caches' => [ |
| 93 | + $primaryCache, |
| 94 | + ['class' => ArrayCache::class], |
| 95 | + ], |
| 96 | + ]); |
95 | 97 | }; |
96 | 98 | } |
97 | 99 |
|
|
0 commit comments