mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
revert: redis resource cluster support + _APP_CONNECTIONS_CACHE fallback
Cloud production runs four separate single-master+replica Dragonfly deployments (cache, queue-dragonfly, queue-usage, pubsub-dragonfly), not sharded Redis Cluster topology — confirmed by deploy/cloud/values + environments/production/*.values.yaml (Dragonfly Operator with replicas=2 = 1 primary + 1 read replica), and by the dev DSN scheme 'redis://' (not 'redis-cluster://'). So a standard \Redis client suffices for the direct redis resource (timelimit, Lock). Cloud just needs to pass _APP_REDIS_HOST/PORT/USER/ PASS through to the appwrite container — handled in the cloud PR's docker-compose.yml change. This reverts the resource to its original pre-PR shape. The utopia-php/lock cluster-support PR (utopia-php/lock#1) stays open at upstream as a future-ready option if cloud ever moves to actual Redis Cluster mode.
This commit is contained in:
@@ -137,7 +137,7 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S
|
||||
if (!$project->isEmpty() && $project->getId() !== 'console') {
|
||||
$accessedAt = $project->getAttribute('accessedAt', 0);
|
||||
if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_PROJECT_ACCESS)) > $accessedAt) {
|
||||
$lock->set('projects', $project->getId());
|
||||
$lock->set('projects', $project->getId(), 'accessedAt', DateTime::now());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -392,7 +392,7 @@ Http::init()
|
||||
if ($project->getId() !== 'console') {
|
||||
$accessedAt = $project->getAttribute('accessedAt', 0);
|
||||
if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_PROJECT_ACCESS)) > $accessedAt) {
|
||||
$lock->set('projects', $project->getId());
|
||||
$lock->set('projects', $project->getId(), 'accessedAt', DateTime::now());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-17
@@ -193,25 +193,12 @@ $container->set('cache', function (Group $pools, Telemetry $telemetry) {
|
||||
}, ['pools', 'telemetry']);
|
||||
|
||||
$container->set('redis', function () {
|
||||
// Prefer _APP_CONNECTIONS_CACHE (URI form, used by cloud and the pool layer)
|
||||
// so that direct \Redis consumers (timelimit, Lock) match the same backend
|
||||
// as the cache pool. Fall back to _APP_REDIS_* for CE-style configs.
|
||||
$cacheDsn = System::getEnv('_APP_CONNECTIONS_CACHE', '');
|
||||
if ($cacheDsn !== '') {
|
||||
$first = explode(';', $cacheDsn)[0];
|
||||
$uri = explode('=', $first, 2)[1] ?? $first;
|
||||
$dsn = new DSN($uri);
|
||||
$host = $dsn->getHost();
|
||||
$port = (int) ($dsn->getPort() ?: 6379);
|
||||
$pass = $dsn->getPassword() ?? '';
|
||||
} else {
|
||||
$host = System::getEnv('_APP_REDIS_HOST', 'localhost');
|
||||
$port = (int) System::getEnv('_APP_REDIS_PORT', 6379);
|
||||
$pass = System::getEnv('_APP_REDIS_PASS', '');
|
||||
}
|
||||
$host = System::getEnv('_APP_REDIS_HOST', 'localhost');
|
||||
$port = System::getEnv('_APP_REDIS_PORT', 6379);
|
||||
$pass = System::getEnv('_APP_REDIS_PASS', '');
|
||||
|
||||
$redis = new \Redis();
|
||||
@$redis->pconnect($host, $port);
|
||||
@$redis->pconnect($host, (int) $port);
|
||||
if ($pass) {
|
||||
$redis->auth($pass);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use Closure;
|
||||
use Throwable;
|
||||
use Utopia\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Lock\Distributed as DistributedLock;
|
||||
@@ -51,15 +50,15 @@ final class Lock
|
||||
public function set(
|
||||
string $collection,
|
||||
string $id,
|
||||
string $attribute = 'accessedAt',
|
||||
?string $value = null,
|
||||
string $attribute,
|
||||
string $value,
|
||||
): void {
|
||||
$key = "lock:platform:{$this->projectInternalId}:{$collection}:{$id}:{$attribute}";
|
||||
$this->execute($key, $collection, function () use ($collection, $id, $attribute, $value) {
|
||||
$this->authorization->skip(fn () => $this->dbForPlatform->updateDocument(
|
||||
$collection,
|
||||
$id,
|
||||
new Document([$attribute => $value ?? DateTime::now()])
|
||||
new Document([$attribute => $value])
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user