36 lines
895 B
C++
36 lines
895 B
C++
#pragma once
|
|
|
|
#include "lib/domain_model/Security.pb.h"
|
|
#include "MDConsumerHandle.h"
|
|
#include "lib/domain_model/SecurityKey.h"
|
|
#include "SecurityPtr.h"
|
|
#include <memory>
|
|
|
|
namespace bts {
|
|
namespace md {
|
|
|
|
// Get security on demand
|
|
// Store security+handle
|
|
struct SecurityCacheImpl;
|
|
class SecurityCache {
|
|
std::shared_ptr<SecurityCacheImpl> _me;
|
|
|
|
public:
|
|
SecurityCache();
|
|
~SecurityCache();
|
|
|
|
//Load security from cache with fallback to database
|
|
SecurityPtr get_security(SecurityKey key);
|
|
|
|
// Get the security if it's in the cache otherwise return nullptr. Does not query security database.
|
|
SecurityPtr try_get_security(SecurityKey key) const;
|
|
|
|
// returns true if the cache was updated
|
|
bool add_live_security(const SecurityPtr& security);
|
|
SecurityPtr add_db_security(const SecurityPtr& security);
|
|
|
|
void flush_to_disk();
|
|
|
|
};
|
|
|
|
}}//ns
|