#NEWLINE# @ tornado . gen . coroutine #NEWLINE# def get( self , tup , dependencies = None ) : #NEWLINE# #INDENT# "Fetch a value from the database, or the cache if it's cached.\n\n        The tup argument has four entries: ('worldprop', wid, locid, key).\n        The meaning of the second and third depend on the database collection\n        (the first entry). This is the same format as dependency keys.\n        Currently this class understands 'instanceprop', 'worldprop',\n        'iplayerprop', 'wplayerprop'.\n        \n        Returns a PropEntry (if found) or None (if not). The value you\n        want is res.val if res is not None.\n\n        (Note that this may return None to indicate that we checked the\n        database earlier, found nothing, and cached that fact.)\n        " #NEWLINE# if ( dependencies is not None ) : #NEWLINE# #INDENT# dependencies . add ( tup ) #NEWLINE# #UNINDENT# ent = self . propmap . get ( tup , None ) #NEWLINE# if ( ent is not None ) : #NEWLINE# #INDENT# if ( not ent . found ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return ent #NEWLINE# #UNINDENT# dbname = tup [ 0 ] #NEWLINE# query = PropCache . query_for_tuple ( tup ) #NEWLINE# res = ( yield motor . Op ( self . app . mongodb [ dbname ] . find_one , query , { #NEWLINE# #INDENT# 'val' : 1 , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# if ( not self ) : #NEWLINE# #INDENT# ent = PropEntry ( None , tup , query , found = False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# val = res [ 'val' ] #NEWLINE# ent = PropEntry ( val , tup , query , found = True ) #NEWLINE# #UNINDENT# self . propmap [ tup ] = ent #NEWLINE# if ent . mutable : #NEWLINE# #INDENT# assert ent . found #NEWLINE# oset = self . objmap . get ( ent . id , None ) #NEWLINE# if ( oset is None ) : #NEWLINE# #INDENT# self . objmap [ ent . id ] = set ( ( ent , ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# oset . add ( ent ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not ent . found ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return ent