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