db.py 文件源码

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

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

        :warning: Permanently deletes entities, use with care!

        Deletes the given entity or entities from the data store. You can only delete
        entities from your app. If there is an error, the function raises a
        subclass of :exc:`datastore_errors.Error`.

        :param keys: Key, str or list of keys or strings to be deleted.
        :type keys: Key | str | list of Key | list of str

        :param config: Optional configuration to use for this request. This must be specified\
        as a keyword argument.
        :type config: dict

        :raises: :exc:`TransactionFailedError`, if the deletion could not be committed.
    """
    if conf["viur.db.caching" ]>0:
        if isinstance( keys, datastore_types.Key ) or isinstance( keys, basestring ): #Just one:
            memcache.delete( str( keys ), namespace=__CacheKeyPrefix__, seconds=__cacheLockTime__  )
        elif isinstance( keys, list ):
            for key in keys:
                assert isinstance( key, datastore_types.Key ) or isinstance( key, basestring )
                memcache.delete( str( key ), namespace=__CacheKeyPrefix__, seconds=__cacheLockTime__  )
    return( datastore.Delete( keys, **kwargs ) )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号