Skip to content

Commit ede136d

Browse files
committed
default config
1 parent 697608c commit ede136d

File tree

1 file changed

+9
-44
lines changed

1 file changed

+9
-44
lines changed

packages/cloud-ops/src/AppConfig.php

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
use Closure;
66
use Craft;
7-
use craft\cachecascade\CascadeCache;
7+
use craft\cache\DbCache;
8+
use craft\db\Table;
89
use craft\helpers\App;
9-
use yii\caching\ArrayCache;
10-
use yii\redis\Cache as RedisCache;
1110

1211
class AppConfig
1312
{
@@ -70,49 +69,15 @@ private function getSessionConfig(): Closure
7069
private function getCacheConfig(): Closure
7170
{
7271
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-
];
72+
$config = $this->tableExists(Table::CACHE) ? [
73+
'class' => DbCache::class,
74+
'cacheTable' => Table::CACHE,
75+
'defaultDuration' => Craft::$app->getConfig()->getGeneral()->cacheDuration,
76+
] : App::cacheConfig();
9077

91-
return Craft::createObject([
92-
'class' => CascadeCache::class,
93-
'caches' => [
94-
$primaryCache,
95-
['class' => ArrayCache::class],
96-
],
97-
]);
98-
};
99-
}
100-
101-
private function resolveValkeyEndpoint(): ?string
102-
{
103-
$srv = App::env('CRAFT_CLOUD_CACHE_SRV');
104-
105-
if ($srv) {
106-
$record = dns_get_record($srv, DNS_SRV);
107-
108-
if (!empty($record)) {
109-
return 'redis://' . $record[0]['target'] . ':' . $record[0]['port'];
110-
}
111-
}
78+
return Craft::createObject($config);
11279

113-
// Deprecated. We are moving to CRAFT_CLOUD_CACHE_SRV for both Fargate and ECS.
114-
// Once every website is moved over, we can disregared this fallback.
115-
return App::env('CRAFT_CLOUD_REDIS_URL');
80+
};
11681
}
11782

11883
private function getQueueConfig(): Closure

0 commit comments

Comments
 (0)