content server caches ObjectDbPtr
use Hash instead of Hash string
use constant instead of raw number
Change-Id: Ib3f5f2d4cd755bfb73b38c2621ad2383522b2621
diff --git a/src/object-db.cc b/src/object-db.cc
index 7567c83..05aca34 100644
--- a/src/object-db.cc
+++ b/src/object-db.cc
@@ -46,6 +46,7 @@
";
ObjectDb::ObjectDb (const fs::path &folder, const std::string &hash)
+ : m_lastUsed (time(NULL))
{
fs::path actualFolder = folder / "objects" / hash.substr (0, 2);
fs::create_directories (actualFolder);
@@ -144,6 +145,9 @@
sqlite3_step (stmt);
//_LOG_DEBUG ("After saving object: " << sqlite3_errmsg (m_db));
sqlite3_finalize (stmt);
+
+ // update last used time
+ m_lastUsed = time(NULL);
}
Ccnx::BytesPtr
@@ -169,9 +173,17 @@
sqlite3_finalize (stmt);
+ // update last used time
+ m_lastUsed = time(NULL);
+
return ret;
}
+time_t
+ObjectDb::secondsSinceLastUse()
+{
+ return (time(NULL) - m_lastUsed);
+}
// sqlite3_int64
// ObjectDb::getNumberOfSegments (const Ccnx::Name &deviceName)