An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(redis): add scheduled cleanup command for Redis keys and enhance cleanup logic
Andras Bacsai9d56d06352a0
diff --git a/app/Console/Commands/CleanupRedis.php b/app/Console/Commands/CleanupRedis.phpindex e16a82be4c..315d1adc7a 100644--- a/app/Console/Commands/CleanupRedis.php+++ b/app/Console/Commands/CleanupRedis.php@@ -13,17 +13,20 @@ class CleanupRedis extends Commandpublic function handle(){- $prefix = config('database.redis.options.prefix');-- $keys = Redis::connection()->keys('*:laravel*');- collect($keys)->each(function ($key) use ($prefix) {+ $redis = Redis::connection('horizon');+ $keys = $redis->keys('*');+ $prefix = config('horizon.prefix');+ foreach ($keys as $key) {$keyWithoutPrefix = str_replace($prefix, '', $key);- Redis::connection()->del($keyWithoutPrefix);- });+ $type = $redis->command('type', [$keyWithoutPrefix]);- $queueOverlaps = Redis::connection()->keys('*laravel-queue-overlap*');- collect($queueOverlaps)->each(function ($key) {- Redis::connection()->del($key);- });+ if ($type === 5) {+ $data = $redis->command('hgetall', [$keyWithoutPrefix]);+ $status = data_get($data, 'status');+ if ($status === 'completed') {+ $redis->command('del', [$keyWithoutPrefix]);+ }+ }+ }}}diff --git a/app/Console/Kernel.php b/app/Console/Kernel.phpindex a6f24aaad6..1c5d3e70bb 100644--- a/app/Console/Kernel.php+++ b/app/Console/Kernel.php@@ -51,6 +51,7 @@ class Kernel extends ConsoleKernel}// $this->scheduleInstance->job(new CleanupStaleMultiplexedConnections)->hourly();+ $this->scheduleInstance->command('cleanup:redis')->everyTenMinutes();if (isDev()) {// Instance Jobs