Sets the tokens cache.

        :param tokens: Completer tokens list.
        :type tokens: tuple or list
347177
def __set_cache(self, tokens):
        

        if DefaultCompleter._DefaultCompleter__tokens.get(self.__language):
            return

        DefaultCompleter._DefaultCompleter__tokens[self.__language] = tokens
1224889
def check_cache(params)
      logger.verbose("TokenRequest checking cache #{@token_cache} for token.")
      result = @cache_driver.find(params)
      logger.info("#{result ? 'Found' : 'Did not find'} token in cache.")
      result
    end
1006343
public void cache(JwtToken token) {
        if (token == null) {
            return;
        }
        Claims claims = token.getClaims();
        if (claims == null) {
            return;
        }
        String jti = claims.getJwtId();
        if (jti == null) {
            return;
        }
        String key = getCacheKey(token);
        long tokenExp = claims.getExpiration() * 1000; // milliseconds
        if (tokenExp == 0) { // in case it's not set, let's give it one hour
            tokenExp = (new Date()).getTime() + 60 * 60 * 1000; // 1 hour
        }
        primaryTable.put(key, Long.valueOf(tokenExp));
    }
792225
public static Token[] optimize(Token[] tokens) {
        if (tokens == null) {
            return null;
        }

        String firstVal = null;
        String lastVal = null;

        if (tokens.length == 1) {
            if (tokens[0].getType() == TokenType.TEXT) {
                firstVal = tokens[0].getDefaultValue();
            }
        } else if (tokens.length > 1) {
            if (tokens[0].getType() == TokenType.TEXT) {
                firstVal = tokens[0].getDefaultValue();
            }
            if (tokens[tokens.length - 1].getType() == TokenType.TEXT) {
                lastVal = tokens[tokens.length - 1].getDefaultValue();
            }
        }

        if (firstVal != null) {
            String text = trimLeadingWhitespace(firstVal);
            if (!Objects.equals(firstVal, text)) {
                tokens[0] = new Token(text);
            }
        }

        if (lastVal != null && !lastVal.isEmpty()) {
            String text = trimTrailingWhitespace(lastVal);
            if (!Objects.equals(lastVal, text)) {
                tokens[tokens.length - 1] = new Token(text);
            }
        }

        return tokens;
    }
952741
public void addValue(Token[] tokens) {
        if (type == null) {
            type = ItemType.LIST;
        }
        if (!isListableType()) {
            throw new IllegalArgumentException("The type of this item must be 'array', 'list' or 'set'");
        }
        if (tokensList == null) {
            tokensList = new ArrayList<>();
        }
        tokensList.add(tokens);
    }
634216
public function setToken($token, $expires = 7200)
    {
        $this->getCache()->save($this->getCacheKey(), $token, $expires - 1500);

        return $this;
    }
268488
def find_all_cached_entries(query)
      logger.verbose("Searching cache for tokens by keys: #{query.keys}.")
      @token_cache.find do |entry|
        query.map do |k, v|
          (entry.respond_to? k.to_sym) && (v == entry.send(k.to_sym))
        end.reduce(:&)
      end
    end
436293
def collect_tokens(cls, parseresult, mode):
        
        inner = '(%s)' if mode=='parens' else '[%s]'
        if parseresult is None: return []
        tokens = []
        for token in parseresult.asList():
            # If value is a tuple, the token will be a list
            if isinstance(token, list):
                token = cls.recurse_token(token, inner)
                tokens[-1] = tokens[-1] + token
            else:
                if token.strip() == ',': continue
                tokens.append(cls._strip_commas(token))
        return tokens
715451
public Set tokens() {
        if (tokenSet == null) {
            tokenSet = new AbstractSetView() {
                public long size() {
                    return managedObjectsOnDisk.size();
                } // size().

                public Iterator iterator() {
                    final java.util.Iterator tokenIterator = managedObjectsOnDisk.iterator();
                    return new Iterator() {

                        public boolean hasNext()
                        {
                            return tokenIterator.hasNext();
                        } // hasNext().

                        public Object next()
                        {
                            Token token = new Token(FileDirObjectStore.this, ((Long) tokenIterator.next()).longValue());
                            return like(token);
                        } // next().

                        public boolean hasNext(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // hasNext().

                        public Object next(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // next().

                        public Object remove(Transaction transaction)
                                        throws ObjectManagerException
                        {
                            throw new UnsupportedOperationException();
                        } // remove().             
                    }; // new Iterator().
                } // iterator().  
            }; // new AbstractSetView().
        } // if (tokenSet == null). 
        return tokenSet;
    }
1198380
def _parse_tokens(tokens):
    

    index = 0
    parsed_tokens = []

    num_tokens = len(tokens)
    while index < num_tokens:
        tok = Token(*tokens[index])

        assert tok.token_type != token.INDENT
        if tok.token_type == tokenize.NEWLINE:
            # There's only one newline and it's at the end.
            break

        if tok.token_string in '([{':
            (container, index) = _parse_container(tokens, index)
            if not container:
                return None
            parsed_tokens.append(container)
        else:
            parsed_tokens.append(Atom(tok))

        index += 1

    return parsed_tokens
507351
def consume_token(self, tokens, index, tokens_len):
        
        del tokens_len

        if tokens[index].type == TokenType.EndInlineRST:
            return _paste_tokens_line_by_line(tokens,
                                              TokenType.RST,
                                              self.begin,
                                              index + 1)
551173
def setIndexes(self, indexes):
        
        self.__indexes = {}
        for name, index in indexes.items():
            self.__indexes[name] = index
            index.setSchema(self)
620300
def _prepare_reserved_tokens(reserved_tokens):
  """"""
  reserved_tokens = [tf.compat.as_text(tok) for tok in reserved_tokens or []]
  dups = _find_duplicates(reserved_tokens)
  if dups:
    raise ValueError("Duplicates found in tokens: %s" % dups)
  reserved_tokens_re = _make_reserved_tokens_re(reserved_tokens)
  return reserved_tokens, reserved_tokens_re
1332314
def set_headers(self, headers):
        

        logger.debug("Setting headers: " + str(headers))
        self.headers = headers
256205
def get_cache_token(self, token):
        

        if self.conn is None:
            raise CacheException('Redis is not connected')

        token_data = self.conn.get(token)
        token_data = json.loads(token_data) if token_data else None

        return token_data
105065
public function setTokens(array $tokens)
    {
        if (count($tokens) > self::MULTICAST_MAX_TOKENS) {
            throw new \RuntimeException(sprintf('Too many tokens in the list. %s tokens max.', self::MULTICAST_MAX_TOKENS));
        }

        return parent::setTokens($tokens);
    }
1214491
public void skipAll(final TokenType... tokenTypes) {
        Set<TokenType> tokenTypeSet = Sets.newHashSet(tokenTypes);
        while (tokenTypeSet.contains(lexer.getCurrentToken().getType())) {
            lexer.nextToken();
        }
    }