futu_gateway_core/bridge/
cache_bundle.rs1use std::sync::Arc;
7
8use crate::stock_db::StockDb;
9use futu_cache::login_cache::LoginCache;
10use futu_cache::option_chain_statistic::OptionChainStatisticCache;
11use futu_cache::qot_cache::QotCache;
12use futu_cache::qot_right::QotRightCache;
13use futu_cache::risk_free_rate::RiskFreeRateCache;
14use futu_cache::static_data::StaticDataCache;
15use futu_cache::trd_cache::TrdCache;
16use futu_cache::user_profile::UserProfileCache;
17
18#[derive(Clone)]
19pub struct CacheBundle {
20 pub qot_cache: Arc<QotCache>,
21 pub trd_cache: Arc<TrdCache>,
22 pub static_cache: Arc<StaticDataCache>,
23 pub login_cache: Arc<LoginCache>,
24 pub user_profile_cache: Arc<UserProfileCache>,
27 pub qot_right_cache: Arc<QotRightCache>,
29 pub risk_free_rate_cache: Arc<RiskFreeRateCache>,
32 pub option_chain_statistic_cache: Arc<OptionChainStatisticCache>,
35 pub price_reminder_cooldown:
40 Arc<futu_cache::price_reminder_cooldown::PriceReminderCooldownCache>,
41 pub crypto_exchange_cache: Arc<futu_cache::crypto_exchange_cache::CryptoExchangeCache>,
43 pub stock_db: Arc<arc_swap::ArcSwapOption<StockDb>>,
48}
49
50impl CacheBundle {
51 pub fn new() -> Self {
52 Self {
53 qot_cache: Arc::new(QotCache::new()),
54 trd_cache: Arc::new(TrdCache::new()),
55 static_cache: Arc::new(StaticDataCache::new()),
56 login_cache: Arc::new(LoginCache::new()),
57 user_profile_cache: Arc::new(UserProfileCache::new()),
58 qot_right_cache: Arc::new(QotRightCache::new()),
59 risk_free_rate_cache: RiskFreeRateCache::new(),
60 option_chain_statistic_cache: OptionChainStatisticCache::new(),
61 price_reminder_cooldown:
62 futu_cache::price_reminder_cooldown::PriceReminderCooldownCache::new(),
63 crypto_exchange_cache: futu_cache::crypto_exchange_cache::CryptoExchangeCache::new(),
64 stock_db: Arc::new(arc_swap::ArcSwapOption::from(None)),
65 }
66 }
67}
68
69impl Default for CacheBundle {
70 fn default() -> Self {
71 Self::new()
72 }
73}
74
75#[cfg(test)]
76mod tests;