mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
feat: add FtTTLCache to avoid mocking issues
overrides timer in a central location.
This commit is contained in:
@@ -22,6 +22,7 @@ from freqtrade.util.formatters import (
|
||||
round_value,
|
||||
)
|
||||
from freqtrade.util.ft_precise import FtPrecise
|
||||
from freqtrade.util.ft_ttlcache import FtTTLCache
|
||||
from freqtrade.util.measure_time import MeasureTime
|
||||
from freqtrade.util.periodic_cache import PeriodicCache
|
||||
from freqtrade.util.progress_tracker import ( # noqa F401
|
||||
@@ -59,4 +60,5 @@ __all__ = [
|
||||
"print_rich_table",
|
||||
"print_df_rich_table",
|
||||
"CustomProgress",
|
||||
"FtTTLCache",
|
||||
]
|
||||
|
||||
12
freqtrade/util/ft_ttlcache.py
Normal file
12
freqtrade/util/ft_ttlcache.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import time
|
||||
|
||||
from cachetools import TTLCache
|
||||
|
||||
|
||||
class FtTTLCache(TTLCache):
|
||||
"""
|
||||
A TTLCache with a different default timer to allow for easier mocking in tests.
|
||||
"""
|
||||
|
||||
def __init__(self, maxsize, ttl, timer=time.time, getsizeof=None):
|
||||
super().__init__(maxsize=maxsize, ttl=ttl, timer=timer, getsizeof=getsizeof)
|
||||
Reference in New Issue
Block a user