#NEWLINE# def keys_with_prefix( self , prefix , version = None ) : #NEWLINE# #INDENT# if ( self . reverse_key_func is None ) : #NEWLINE# #INDENT# raise ValueError ( 'To use the _with_prefix commands with a custom KEY_FUNCTION, you need to specify a custom REVERSE_KEY_FUNCTION too.' ) #NEWLINE# #UNINDENT# if ( version is None ) : #NEWLINE# #INDENT# version = self . version #NEWLINE# #UNINDENT# db = router . db_for_read ( self . cache_model_class ) #NEWLINE# table = connections [ db ] . ops . quote_name ( self . _table ) #NEWLINE# prefix = self . make_key ( ( prefix + '%' ) , version = version ) #NEWLINE# with connections [ db ] . cursor ( ) as cursor : #NEWLINE# #INDENT# cursor . execute ( 'SELECT cache_key FROM {table}\n                   WHERE cache_key LIKE %s AND\n                         expires >= %s' . format ( table = table ) , ( prefix , self . _now ( ) ) ) #NEWLINE# rows = cursor . fetchall ( ) #NEWLINE# full_keys = { row [ 0 ] for row in rows } #NEWLINE# keys = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for full_key in row : #NEWLINE# #INDENT# ( key , key_prefix , key_version ) = self . reverse_key_func ( full_key ) #NEWLINE# if ( key_version == version ) : #NEWLINE# #INDENT# keys [ key ] = key_version #NEWLINE# #UNINDENT# #UNINDENT# return set ( six . iterkeys ( keys ) )