merged PingRotate into PingScheduler; fixed save/load of cache to/from file; started...
[pingcheck] / src / dns / dnscache.h
index 7a0fbe8..eaca600 100644 (file)
@@ -53,6 +53,7 @@ struct Cname
 
     Cname();
     Cname(const std::string &host, const uint32_t ttl);
+    Cname(const std::string &host, const TimeToLive &ttl);
 
     // serialization
     friend class boost::serialization::access;
@@ -72,6 +73,10 @@ struct Cname
 };
 typedef std::map<std::string, Cname> cname_map_type;
 
+/// constant to give as cache_file arg to DnsCache constructor
+/// indicating that no cache file should be used
+const std::string DO_NOT_USE_CACHE_FILE = "do not use cache file!";
+
 
 // -----------------------------------------------------------------------------
 // DnsCache
@@ -85,9 +90,8 @@ public:
     ~DnsCache();
 
     // accessed from ResolverBase subclasses
-    void update(const std::string &hostname, const HostAddressVec &new_data);
+    void update(const std::string &hostname, const HostAddressVec &new_ips);
     void update(const std::string &hostname, const Cname &cname);
-    void update(const std::string &hostname, const uint32_t ttl);
 
     // retrieval
     HostAddressVec get_ips(const std::string &hostname,
@@ -112,6 +116,7 @@ private:
     void schedule_save(const boost::system::error_code &error);
     void save_to_cachefile();
     void load_from_cachefile();
+    std::string key_for_hostname(const std::string &hostname) const;
 
 };