public function cleanup()
    {
        $hosts   = $this->redis->smembers(self::redisKey());
        $workers = $this->redis->smembers(Worker::redisKey());
        $cleaned = array('hosts' => array(), 'workers' => array());

        foreach ($hosts as $hostname) {
            $host = new static($hostname);

            if (!$this->redis->exists(self::redisKey($host))) {
                $this->redis->srem(self::redisKey(), (string)$host);
                $cleaned['hosts'][] = (string)$host;
            } else {
                $host_workers = $this->redis->smembers(self::redisKey($host));

                foreach ($host_workers as $host_worker) {
                    if (!in_array($host_worker, $workers)) {
                        $cleaned['workers'][] = $host_worker;

                        $this->redis->srem(self::redisKey($host), $host_worker);
                    }
                }
            }
        }

        return $cleaned;
    }
public function cleanup()
    {
        $hosts   = $this->redis->smembers(self::redisKey());
        $workers = $this->redis->smembers(Worker::redisKey());
        $cleaned = array('hosts' => array(), 'workers' => array());

        foreach ($hosts as $hostname) {
            $host = new static($hostname);

            if (!$this->redis->exists(self::redisKey($host))) {
                $this->redis->srem(self::redisKey(), (string)$host);
                $cleaned['hosts'][] = (string)$host;
            } else {
                $host_workers = $this->redis->smembers(self::redisKey($host));

                foreach ($host_workers as $host_worker) {
                    if (!in_array($host_worker, $workers)) {
                        $cleaned['workers'][] = $host_worker;

                        $this->redis->srem(self::redisKey($host), $host_worker);
                    }
                }
            }
        }

        return $cleaned;
    }
public function cleanup ( ) { $ hosts = $ this -> redis -> smembers ( self :: redisKey ( ) ) ; $ workers = $ this -> redis -> smembers ( Worker :: redisKey ( ) ) ; $ cleaned = array ( 'hosts' => array ( ) , 'workers' => array ( ) ) ; foreach ( $ hosts as $ hostname ) { $ host = new static ( $ hostname ) ; if ( ! $ this -> redis -> exists ( self :: redisKey ( $ host ) ) ) { $ this -> redis -> srem ( self :: redisKey ( ) , ( string ) $ host ) ; $ cleaned [ 'hosts' ] [ ] = ( string ) $ host ; } else { $ host_workers = $ this -> redis -> smembers ( self :: redisKey ( $ host ) ) ; foreach ( $ host_workers as $ host_worker ) { if ( ! in_array ( $ host_worker , $ workers ) ) { $ cleaned [ 'workers' ] [ ] = $ host_worker ; $ this -> redis -> srem ( self :: redisKey ( $ host ) , $ host_worker ) ; } } } } return $ cleaned ; }
Cleans up any dead hosts

@return array List of cleaned hosts
Cleans up any dead hosts