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