#NEWLINE# def get_object( model , cid , engine_name = None , connection = None ) : #NEWLINE# #INDENT# '\n    Get cached object from redis\n    \n    if id is None then return None:\n    ' #NEWLINE# from uliweb import settings #NEWLINE# if ( not id ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( not check_enable ( ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# redis = get_redis ( ) #NEWLINE# if ( not redis ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# tablename = ( model . _alias or model . tablename ) #NEWLINE# info = settings . get_var ( ( 'OBJCACHE_TABLES/%s' % tablename ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( info is None ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# _id = get_id ( ( engine_name or model . get_engine_name ( ) ) , tablename , cid ) #NEWLINE# try : #NEWLINE# #INDENT# log . debug ( ( 'Try to find objcache:get:table=%s:id=[%s]' % ( tablename , info ) ) ) #NEWLINE# if redis . exists ( _id ) : #NEWLINE# #INDENT# v = redis . hgetall ( _id ) #NEWLINE# o = model . load ( v , from_ = 'dump' ) #NEWLINE# log . debug ( 'Found!' ) #NEWLINE# return o #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . debug ( 'Not Found!' ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# log . exception ( e )