<s> from collections import deque <EOL> class Cache ( object ) : <EOL> def __init__ ( self , max_length = <NUM_LIT:0> ) : <EOL> self . max_length = max_length <EOL> self . _items = deque ( ) <EOL> def __len__ ( self ) : <EOL> return len ( self . _items ) <EOL> def append ( self , item ) : <EOL> self . _items . append ( item ) <EOL> if self . max_length : <EOL> while len ( self . _items ) > self . max_length : <EOL> self . _items . popleft ( ) <EOL> @ property <EOL> def items ( self ) : <EOL> return self . _items <EOL> def consume ( self ) : <EOL> while self . _items : <EOL> yield self . _items . popleft ( ) </s>
