def load( self, Object_type, object_id, revision = None ): """ Load the object corresponding to the given object id from the database and return it, or None if the object_id is unknown. If a revision is provided, a specific revision of the object will be loaded. @type Object_type: type @param Object_type: class of the object to load @type object_id: unicode @param object_id: id of the object to load @type revision: int or NoneType @param revision: revision of the object to load (optional) @rtype: Object_type or NoneType @return: loaded object, or None if no match """ if revision or Object_type in self.CLASSES_NOT_TO_CACHE: cache = None else: cache = self.__get_cache_connection() if cache: # don't bother caching old revisions obj = cache.get( Persistent.make_cache_key( Object_type, object_id ) ) if obj: return obj obj = self.select_one( Object_type, Object_type.sql_load( object_id, revision ) ) if obj and cache: cache.set( obj.cache_key, obj ) return obj
def uncache_many( self, Object_type, obj_ids ): cache = self.__get_cache_connection() if not cache: return for obj_id in obj_ids: cache.delete( Persistent.make_cache_key( Object_type, obj_id ) )