cache.py 文件源码

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

项目:bowtie 作者: jwkvam 项目源码 文件源码
def load(key):
    """Load the value stored with the key.

    Parameters
    ----------
    key : str
        The key to lookup the value stored.

    Returns
    -------
    object
        The value if the key exists in the cache, otherwise None.

    """
    signal = 'cache_load'
    event = LightQueue(1)
    if flask.has_request_context():
        emit(signal, {'data': pack(key)}, callback=event.put)
    else:
        sio = flask.current_app.extensions['socketio']
        sio.emit(signal, {'data': pack(key)}, callback=event.put)
    return msgpack.unpackb(bytes(event.get(timeout=10)), encoding='utf8')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号