From af2f8756c5cf2acef2b0783668cc9a83c5b4c7ca Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 19 Apr 2023 15:29:59 -0400 Subject: [PATCH] binance: use `@async_lifo_cache` on `.get_mkt_info()` ep --- piker/brokers/binance.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/piker/brokers/binance.py b/piker/brokers/binance.py index 0f8d5f77..915902fb 100644 --- a/piker/brokers/binance.py +++ b/piker/brokers/binance.py @@ -41,6 +41,7 @@ import numpy as np import tractor import wsproto +from .._cacheables import async_lifo_cache from ..accounting._mktinfo import ( Asset, MktPair, @@ -483,20 +484,12 @@ async def open_history_client( yield get_ohlc, {'erlangs': 3, 'rate': 3} -# TODO: bleh, didn't we have an async version of -# this at some point? -# @lru_cache +@async_lifo_cache() async def get_mkt_info( fqme: str, - _cache: dict[str, MktPair] = {} - ) -> tuple[MktPair, Pair]: - both = _cache.get(fqme) - if both: - return both - async with open_cached_client('binance') as client: pair: Pair = await client.exch_info(fqme.upper()) @@ -517,7 +510,6 @@ async def get_mkt_info( broker='binance', ) both = mkt, pair - _cache[fqme] = both return both