def cache(self, CachableItem):
        """Updates cache area with latest information
        """
        _cachedItem = self.get(CachableItem)
        if not _cachedItem:
            _dirtyCachedItem = self.mapper.get(CachableItem)
            logger.debug("new cachable item added to sql cache area {id: %s, type: %s}", str(_dirtyCachedItem.getId()), str(_dirtyCachedItem.__class__))
            cached_item = self.session.merge(_dirtyCachedItem)
            notify(CacheObjectCreatedEvent(cached_item, self))
            return cached_item
        else:
            _newCacheItem = self.mapper.get(CachableItem)
            if _cachedItem != _newCacheItem:
                logger.debug("Cachable item modified in sql cache area {id: %s, type: %s}", str(_newCacheItem.getId()), str(_newCacheItem.__class__))
                cached_item = self.session.merge(_newCacheItem)
                notify(CacheObjectModifiedEvent(cached_item, self))
                return cached_item
        return False
def cache ( self , CachableItem ) : _cachedItem = self . get ( CachableItem ) if not _cachedItem : _dirtyCachedItem = self . mapper . get ( CachableItem ) logger . debug ( "new cachable item added to sql cache area {id: %s, type: %s}" , str ( _dirtyCachedItem . getId ( ) ) , str ( _dirtyCachedItem . __class__ ) ) cached_item = self . session . merge ( _dirtyCachedItem ) notify ( CacheObjectCreatedEvent ( cached_item , self ) ) return cached_item else : _newCacheItem = self . mapper . get ( CachableItem ) if _cachedItem != _newCacheItem : logger . debug ( "Cachable item modified in sql cache area {id: %s, type: %s}" , str ( _newCacheItem . getId ( ) ) , str ( _newCacheItem . __class__ ) ) cached_item = self . session . merge ( _newCacheItem ) notify ( CacheObjectModifiedEvent ( cached_item , self ) ) return cached_item return False
Updates cache area with latest information