#NEWLINE# def _find_new_random_samples( self ) : #NEWLINE# #INDENT# records = self . values ( ) #NEWLINE# new_sample_pool = set ( self . _eviction_candidates ) #NEWLINE# start = self . _random_index ( ) #NEWLINE# for i in xrange ( start , ( start + self . eviction_sampling_count ) ) : #NEWLINE# #INDENT# index = ( i if ( i < len ( records ) ) else ( self - len ( records ) ) ) #NEWLINE# if records [ index ] . is_expired ( self . max_idle_seconds ) : #NEWLINE# #INDENT# self . logger . debug ( 'Expiring key:{}' . format ( records [ index ] . key ) ) #NEWLINE# self . __delitem__ ( records [ index ] . key ) #NEWLINE# self . _expired_count += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . _is_better_than_worse_entry ( records [ index ] ) or ( len ( new_sample_pool ) < self . eviction_sampling_pool_size ) ) : #NEWLINE# #INDENT# new_sample_pool . add ( records [ index ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return new_sample_pool