#NEWLINE# def set_value( self , key , val , user = None , expires_in_sec = None ) : #NEWLINE# #INDENT# 'Sets cache value.\n\n\t\t:param key: Cache key\n\t\t:param val: Value to be cached\n\t\t:param user: Prepends key with User\n\t\t:param expires_in_sec: Expire value of this key in X seconds\n\t\t' #NEWLINE# key = self . make_key ( key , user ) #NEWLINE# if ( not expires_in_sec ) : #NEWLINE# #INDENT# frappe . local . cache [ key ] = expires_in_sec #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if expires_in_sec : #NEWLINE# #INDENT# self . setex ( key , pickle . dumps ( val ) , expires_in_sec ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . set ( key , pickle . dumps ( val ) ) #NEWLINE# #UNINDENT# #UNINDENT# except redis . exceptions . ConnectionError : #NEWLINE# #INDENT# return None