当前位置: 首页>>代码示例>>Python>>正文


Python pylru.lrucache方法代码示例

本文整理汇总了Python中pylru.lrucache方法的典型用法代码示例。如果您正苦于以下问题:Python pylru.lrucache方法的具体用法?Python pylru.lrucache怎么用?Python pylru.lrucache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylru的用法示例。


在下文中一共展示了pylru.lrucache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, env, db, bp, daemon, mempool, shutdown_event):
        env.max_send = max(350000, env.max_send)
        self.env = env
        self.db = db
        self.bp = bp
        self.daemon = daemon
        self.mempool = mempool
        self.peer_mgr = PeerManager(env, db)
        self.shutdown_event = shutdown_event
        self.logger = util.class_logger(__name__, self.__class__.__name__)
        self.servers = {}
        self.sessions = set()
        self.max_subs = env.max_subs
        self.cur_group = SessionGroup(0)
        self.txs_sent = 0
        self.start_time = time.time()
        self.history_cache = pylru.lrucache(256)
        self.notified_height = None
        # Cache some idea of room to avoid recounting on each subscription
        self.subs_room = 0
        # Masternode stuff only for such coins
        if issubclass(env.coin.SESSIONCLS, DashElectrumX):
            self.mn_cache_height = 0
            self.mn_cache = []

        self.session_event = Event()

        # Set up the RPC request handlers
        cmds = ('add_peer daemon_url disconnect getinfo groups log peers '
                'query reorg sessions stop'.split())
        LocalRPC.request_handlers = {cmd: getattr(self, 'rpc_' + cmd)
                                     for cmd in cmds} 
开发者ID:lbryio,项目名称:torba,代码行数:34,代码来源:session.py

示例2: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, options):
        """Initializes an LruBackend.

        Args:
          options: a dictionary that contains configuration options.
        """
        capacity = options[u"capacity"] if u"capacity" in options else 200
        self._cache = pylru.lrucache(capacity) 
开发者ID:cloudendpoints,项目名称:endpoints-management-python,代码行数:10,代码来源:caches.py

示例3: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.query_executor = None
        self.websocket = None
        self.metrics = ServerLoadData()
        self.metrics_loop = None
        self.running = False
        if self.env.websocket_host is not None and self.env.websocket_port is not None:
            self.websocket = AdminWebSocket(self)
        self.search_cache = self.bp.search_cache
        self.search_cache['search'] = lrucache(10000)
        self.search_cache['resolve'] = lrucache(10000) 
开发者ID:lbryio,项目名称:lbry-sdk,代码行数:14,代码来源:session.py

示例4: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, coin, url, max_workqueue=10, init_retry=0.25,
                 max_retry=4.0):
        self.coin = coin
        self.logger = class_logger(__name__, self.__class__.__name__)
        self.set_url(url)
        # Limit concurrent RPC calls to this number.
        # See DEFAULT_HTTP_WORKQUEUE in bitcoind, which is typically 16
        self.workqueue_semaphore = asyncio.Semaphore(value=max_workqueue)
        self.init_retry = init_retry
        self.max_retry = max_retry
        self._height = None
        self.available_rpcs = {}
        self.connector = aiohttp.TCPConnector()
        self._block_hash_cache = lrucache(100000)
        self._block_cache = lrucache(10000) 
开发者ID:lbryio,项目名称:lbry-sdk,代码行数:17,代码来源:daemon.py

示例5: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, target_addr, bind_addr, via=None, **kwargs):
        self.target_addr = target_addr
        self.bind_addr = bind_addr
        self.via = via or ViaNamespace(ClientClass=UDPClient)
        self.removed = None
        self.kwargs = kwargs

        def callback(key, value):
            self.removed = (key, value)

        self.via_clients = pylru.lrucache(256, callback) 
开发者ID:guyingbo,项目名称:shadowproxy,代码行数:13,代码来源:udpserver.py

示例6: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, cipher, bind_addr, via=None, **kwargs):
        self.cipher = cipher
        self.bind_addr = bind_addr
        self.via = via or ViaNamespace(ClientClass=UDPClient)
        self.removed = None
        self.kwargs = kwargs

        def callback(key, value):
            self.removed = (key, value)

        self.via_clients = pylru.lrucache(256, callback) 
开发者ID:guyingbo,项目名称:shadowproxy,代码行数:13,代码来源:udpserver.py

示例7: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, bind_addr, via=None, **kwargs):
        self.bind_addr = bind_addr
        self.via = via or ViaNamespace(ClientClass=UDPClient)
        self.removed = None
        self.kwargs = kwargs

        def callback(key, value):
            self.removed = (key, value)

        self.via_clients = pylru.lrucache(256, callback)
        self.bind_socks = weakref.WeakValueDictionary() 
开发者ID:guyingbo,项目名称:shadowproxy,代码行数:13,代码来源:udpserver.py

示例8: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, via=None):
        self.via = via
        self.removed = None

        def callback(key, value):
            self.removed = (key, value)

        import pylru

        self.addr2client = pylru.lrucache(256, callback) 
开发者ID:guyingbo,项目名称:shadowproxy,代码行数:12,代码来源:shadowproxy_v0_2_5.py

示例9: __init__

# 需要导入模块: import pylru [as 别名]
# 或者: from pylru import lrucache [as 别名]
def __init__(self, config=None):
        self.config = config or {}
        self.db: Database = self.config.get('db') or Database(
            os.path.join(self.path, "blockchain.db")
        )
        self.db.ledger = self
        self.headers: Headers = self.config.get('headers') or self.headers_class(
            os.path.join(self.path, "headers")
        )
        self.headers.checkpoints = self.checkpoints
        self.network: Network = self.config.get('network') or Network(self)
        self.network.on_header.listen(self.receive_header)
        self.network.on_status.listen(self.process_status_update)
        self.network.on_connected.listen(self.join_network)

        self.accounts = []
        self.fee_per_byte: int = self.config.get('fee_per_byte', self.default_fee_per_byte)

        self._on_transaction_controller = StreamController()
        self.on_transaction = self._on_transaction_controller.stream
        self.on_transaction.listen(
            lambda e: log.info(
                '(%s) on_transaction: address=%s, height=%s, is_verified=%s, tx.id=%s',
                self.get_id(), e.address, e.tx.height, e.tx.is_verified, e.tx.id
            )
        )

        self._on_address_controller = StreamController()
        self.on_address = self._on_address_controller.stream
        self.on_address.listen(
            lambda e: log.info('(%s) on_address: %s', self.get_id(), e.addresses)
        )

        self._on_header_controller = StreamController()
        self.on_header = self._on_header_controller.stream
        self.on_header.listen(
            lambda change: log.info(
                '%s: added %s header blocks, final height %s',
                self.get_id(), change, self.headers.height
            )
        )
        self._download_height = 0

        self._on_ready_controller = StreamController()
        self.on_ready = self._on_ready_controller.stream

        self._tx_cache = pylru.lrucache(self.config.get("tx_cache_size", 100_000))
        self._update_tasks = TaskGroup()
        self._other_tasks = TaskGroup()  # that we dont need to start
        self._utxo_reservation_lock = asyncio.Lock()
        self._header_processing_lock = asyncio.Lock()
        self._address_update_locks: DefaultDict[str, asyncio.Lock] = defaultdict(asyncio.Lock)

        self.coin_selection_strategy = None
        self._known_addresses_out_of_sync = set()

        self.fee_per_name_char = self.config.get('fee_per_name_char', self.default_fee_per_name_char)
        self._balance_cache = pylru.lrucache(100000) 
开发者ID:lbryio,项目名称:lbry-sdk,代码行数:60,代码来源:ledger.py


注:本文中的pylru.lrucache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。