#NEWLINE# def has_item( self , url , timeout = None ) : #NEWLINE# #INDENT# '\n        Test if required item exists in the cache.\n        ' #NEWLINE# _hash = self . build_hash ( url ) #NEWLINE# if ( timeout is not None ) : #NEWLINE# #INDENT# ts = ( int ( time . time ( ) ) - timeout ) #NEWLINE# query = { #NEWLINE# #INDENT# '_id' : _hash , #NEWLINE# 'timestamp' : { #NEWLINE# #INDENT# '$gt' : ts , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# query = { #NEWLINE# #INDENT# '_id' : _hash , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# doc = self . db . cache . find_one ( query , { #NEWLINE# #INDENT# 'id' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# return ( doc is not None )