#NEWLINE# def __call__( self , key , f , time_expire = 300 ) : #NEWLINE# #INDENT# key = ( '%s/%s' % ( self . request . application , key ) ) #NEWLINE# dt = time_expire #NEWLINE# value = None #NEWLINE# obj = self . client . get ( key ) #NEWLINE# if ( obj and ( ( dt is None ) or ( obj [ 0 ] > ( time . time ( ) - dt ) ) ) ) : #NEWLINE# #INDENT# value = obj [ 1 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( f is None ) : #NEWLINE# #INDENT# if value : #NEWLINE# #INDENT# self . client . delete ( key ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# value = f ( ) #NEWLINE# self . client . set ( key , ( time . time ( ) , value ) , time = time_expire ) #NEWLINE# #UNINDENT# #UNINDENT# return value