Remove token from cache for saving memory

@param string|\Gems_Tracker_Token $token
@return \Gems_Tracker (continuation pattern)
331324
public function removeToken($token)
    {
        if ($token instanceof \Gems_Tracker_Token) {
            $tokenId = $token->getTokenId();
        } else {
            $tokenId = $token;
        }
        unset($this->_tokens[$tokenId]);

        return $this;
    }
1132889
public function moveToToken(Token $token) {

      if (!$token->isValid()) {
        $this->setValid(false);
        return new Token();
      }

      $tokenIndex = $token->getIndex();


      foreach ($this->collection as $index => $collectionToken) {
        if ($collectionToken->getIndex() === $tokenIndex) {
          $this->setPosition($index);
          return $collectionToken;
        }
      }

      $this->setValid(false);
      return new Token();
    }
1368450
protected function _setToken($token)
    {
        //Prevents an empty value is serialized
        if (!$token) {
            return $token;
        }
        $token = is_string($token) ? $token : serialize($token);

        return substr(Security::hash($token, 'sha1', Configure::read('Tokens.tokenSalt')), 0, 25);
    }
432950
public function move(Token $token) {
			$this->begin = $token->begin;
			$this->end = $token->end;

			unset($this->after, $this->before);
		}
3031
public function setToken($token = null)
    {
        if (isset($token)) {
            return $this->token = $token;
        }

        return $this->token = gplcart_string_encode(crypt(session_id(), $this->config->getKey()));
    }
919381
public function isCompleted(\Gems_Tracker_Token $token)
    {
        $source = $this->getSource();
        return $source->isCompleted($token, $this->_surveyId, $this->_gemsSurvey['gsu_surveyor_id']);
    }
1359350
public function update(Token $token)
    {
        $this->om->persist($token);
        $this->om->flush();

        return $token;
    }
613817
protected function tokenExpired($token)
    {
        $expirationTime = strtotime($token['created_at']) + $this->expires;
        return $expirationTime < $this->getCurrentTime();
    }
750676
public function expireByToken($token)
    {
        $token = $this->findByToken($token);

        if (! is_null($token)) {
            return $token->expire();
        }
    }
1008236
private function saveScrefToken($token)
    {
        /**
         * 保存到cookie
         */
        $this->vitex->res->setCookie("csrf_token",$token);
        /**
         * 保存到http header中
         */
        $this->vitex->res->setHeader("X-Csrf-Token",$token);
        /**
         * 设置到 response中传递给模板变量
         */
        $this->vitex->res->set("csrf_token",$token);
    }
903728
public static function delete($token)
    {
        if (is_string($token)) {
            $token = self::read($token);
        }

        if (!($token instanceof \Token\Model\Entity\Token)) {
            return false;
        }

        return TableRegistry::get('Token.Tokens')->delete($token);
    }
1004684
public function setToken($token)
    {
        $this->_tokenString = (string) $token;
        $this->_token       = $token;
        return $this;
    }
1337651
protected function _fillAttributeMap(\Gems_Tracker_Token $token)
    {
        $values[$this->_attributeMap['respondentid']]   =
                substr($token->getRespondentId(), 0, $this->attributeSize);
        $values[$this->_attributeMap['organizationid']] =
                substr($token->getOrganizationId(), 0, $this->attributeSize);
        $values[$this->_attributeMap['consentcode']]    =
                substr($token->getConsentCode(), 0, $this->attributeSize);
        $values[$this->_attributeMap['resptrackid']]    =
                substr($token->getRespondentTrackId(), 0, $this->attributeSize);

        return $values;
    }
42736
public function deleteToken($token)
    {
        $tokenObject = $this->findToken($token);

        if ($tokenObject == null) {
            return (false);
        }
        $this->call($this->tyrUrl . '/' . $this->version . '/users/' . $this->user->id . '/keys/' . $tokenObject->id .'/', 'DELETE');
        return true;
    }
139846
private function deleteToken($token)
    {
        $obj = $this->modelFactory()->create(LostPasswordToken::class);
        $obj->setToken($token);
        $obj->delete();
    }
194686
public static function check( $token )
    {
        $token_name = 'token';

        if(Session::exists($token_name) && $token == Session::exists($token_name) )
        {
            Session::delete($token_name);
            return true;
        }
        return false;
    }
24253
public function setAuthorizerAccessToken($token, $expires = 7200)
    {
        return $this->cache->save($this->getAuthorizerAccessTokenKey(), $token, $expires);
    }