keys('*'); $prefix = config('horizon.prefix'); foreach ($keys as $key) { $keyWithoutPrefix = str_replace($prefix, '', $key); $type = $redis->command('type', [$keyWithoutPrefix]); if ($type === 5) { $data = $redis->command('hgetall', [$keyWithoutPrefix]); $status = data_get($data, 'status'); if ($status === 'completed') { $redis->command('del', [$keyWithoutPrefix]); } } } } }