db.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:server 作者: viur-framework 项目源码 文件源码
def PutAsync( entities, **kwargs ):
    """
        Asynchronously store one or more entities in the data store.

        This function is identical to :func:`server.db.Put`, except that it
        returns an asynchronous object. Call ``get_result()`` on the return value to
        block on the call and get the results.
    """
    if isinstance( entities, Entity ):
        entities._fixUnindexedProperties()
    elif isinstance( entities, List ):
        for entity in entities:
            assert isinstance( entity, Entity )
            entity._fixUnindexedProperties()
    if conf["viur.db.caching" ]>0:
        if isinstance( entities, Entity ): #Just one:
            if entities.is_saved(): #Its an update
                memcache.delete( str( entities.key() ), namespace=__CacheKeyPrefix__, seconds=__cacheLockTime__  )
        elif isinstance( entities, list ):
            for entity in entities:
                assert isinstance( entity, Entity )
                if entity.is_saved(): #Its an update
                    memcache.delete( str( entity.key() ), namespace=__CacheKeyPrefix__, seconds=__cacheLockTime__  )
    return( datastore.PutAsync( entities, **kwargs ) )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号