#pragma once #include "MDConsumerHandle.h" #include "SecurityPtr.h" #include "domain/security_key.h" #include "lib/domain_model/Security.pb.h" #include "lib/md/ExchangeSecurityKey.h" #include namespace bts { namespace md { // Get security on demand // Store security+handle struct SecurityCacheImpl; class SecurityCache { std::shared_ptr _me; public: SecurityCache(); ~SecurityCache(); // Load security from cache with fallback to database const Security *get_security(SecurityKey key); // Load all securities from cache, no fallback to database std::vector get_securities(); // Get the security if it's in the cache otherwise return nullptr. Does not // query security database. const Security *try_get_security(SecurityKey key) const; const Security *try_get_security(ExchangeSecurityKey key) const; // returns true if the cache was updated bool add_live_security(const SecurityPtr &security); const Security *add_db_security(const SecurityPtr &security); void flush_to_disk(); }; } // namespace md } // namespace bts