original_docstring: 
          Looks up the title in cache, validates it and returns it if valid
          
docstring: Looks up the title in cache, validates it and returns it if valid
docstring_tokens: Looks up the title in cache validates it and returns it if valid
code: def _fetch_item_from_cache(self, title):
          """
          Looks up the title in cache, validates it and returns it if valid
          """
  
          # Get item from cache
          cached_item = self.cache.get(title)
          # If it's not expired, go with it
          if cached_item and not cached_item.is_expired():
              logger.debug("Cache hit for '%s'", title)
              return cached_item
          # If it's expired, query the API using if-modified-since to see if cache is still valid
          elif cached_item:
              logger.debug("Cache expired for '%s'", title)
              modified_since = http_datestring_from_datetime(cached_item.last_modified)
              params = {'q': title, 'type': 'track'}
              headers = {'If-Modified-Since': modified_since}
              r = requests.get(SPOTIFY_API_SEARCH_TRACK_URL, params=params, headers=headers)
  
              # Something bad happened with the API that we can't recover from
              if r.status_code not in VALID_API_STATUSCODES:
                  raise ApiException(r.status_code)
              # If we get statuscode 304, we can still use the cached item
              if r.status_code == 304:
                  logger.debug("Cache still valid for '%s'", title)
                  return cached_item
              else:
                  logger.debug("Cache invalidated for '%s'", title)
                  self.cache.remove(title)
                  return None
code_tokens: def _fetch_item_from_cache ( self , title ) : cached_item = self . cache . get ( title ) if cached_item and not cached_item . is_expired ( ) : logger . debug ( "Cache hit for '%s'" , title ) return cached_item elif cached_item : logger . debug ( "Cache expired for '%s'" , title ) modified_since = http_datestring_from_datetime ( cached_item . last_modified ) params = { 'q' : title , 'type' : 'track' } headers = { 'If-Modified-Since' : modified_since } r = requests . get ( SPOTIFY_API_SEARCH_TRACK_URL , params = params , headers = headers ) if r . status_code not in VALID_API_STATUSCODES : raise ApiException ( r . status_code ) if r . status_code == 304 : logger . debug ( "Cache still valid for '%s'" , title ) return cached_item else : logger . debug ( "Cache invalidated for '%s'" , title ) self . cache . remove ( title ) return None
short_docstring: Looks up the title in cache, validates it and returns it if valid
short_docstring_tokens: Looks up the title in cache validates it and returns it if valid
comment: """
          Looks up the title in cache, validates it and returns it if valid
          """$SEP$# Get item from cache$SEP$# If it's not expired, go with it$SEP$# If it's expired, query the API using if-modified-since to see if cache is still valid$SEP$# Something bad happened with the API that we can't recover from$SEP$# If we get statuscode 304, we can still use the cached item