Datastore/src/DatastoreSessionHandler.php
public function gc($maxlifetime)
    {
        if ($this->gcLimit === 0) {
            return true;
        }
        try {
            $query = $this->datastore->query()
                ->kind($this->kind)
                ->filter('t', '<', time() - $maxlifetime)
                ->order('t')
                ->keysOnly()
                ->limit($this->gcLimit);
            $result = $this->datastore->runQuery(
                $query,
                ['namespaceId' => $this->namespaceId]
            );
            $keys = [];
            /* @var Entity $e */
            foreach ($result as $e) {
                $keys[] = $e->key();
            }
            if (!empty($keys)) {
                $this->datastore->deleteBatch($keys);
            }
        } catch (Exception $e) {
            trigger_error(
                sprintf('Session gc failed: %s', $e->getMessage()),
                E_USER_WARNING
            );
            return false;
        }
        return true;
    }
public function gc($maxlifetime)
    {
        if ($this->gcLimit === 0) {
            return true;
        }
        try {
            $query = $this->datastore->query()
                ->kind($this->kind)
                ->filter('t', '<', time() - $maxlifetime)
                ->order('t')
                ->keysOnly()
                ->limit($this->gcLimit);
            $result = $this->datastore->runQuery(
                $query,
                ['namespaceId' => $this->namespaceId]
            );
            $keys = [];
            /* @var Entity $e */
            foreach ($result as $e) {
                $keys[] = $e->key();
            }
            if (!empty($keys)) {
                $this->datastore->deleteBatch($keys);
            }
        } catch (Exception $e) {
            trigger_error(
                sprintf('Session gc failed: %s', $e->getMessage()),
                E_USER_WARNING
            );
            return false;
        }
        return true;
    }
public function gc ( $ maxlifetime ) { if ( $ this -> gcLimit === 0 ) { return true ; } try { $ query = $ this -> datastore -> query ( ) -> kind ( $ this -> kind ) -> filter ( 't' , '<' , time ( ) - $ maxlifetime ) -> order ( 't' ) -> keysOnly ( ) -> limit ( $ this -> gcLimit ) ; $ result = $ this -> datastore -> runQuery ( $ query , [ 'namespaceId' => $ this -> namespaceId ] ) ; $ keys = [ ] ; /* @var Entity $e */ foreach ( $ result as $ e ) { $ keys [ ] = $ e -> key ( ) ; } if ( ! empty ( $ keys ) ) { $ this -> datastore -> deleteBatch ( $ keys ) ; } } catch ( Exception $ e ) { trigger_error ( sprintf ( 'Session gc failed: %s' , $ e -> getMessage ( ) ) , E_USER_WARNING ) ; return false ; } return true ; }
Delete the old session data from Cloud Datastore.
Delete the old session data from Cloud Datastore .