From 37629aaf87c300ee5f9a56ecbbcdc1c4bb7db97f Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 13 Mar 2017 12:22:06 -0700 Subject: [PATCH] Use cache on requests to decrease DB load. --- controller/EmbeddedNetworkController.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index b731db832..6fc5ba203 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -61,6 +61,9 @@ using json = nlohmann::json; // Nodes are considered active if they've queried in less than this long #define ZT_NETCONF_NODE_ACTIVE_THRESHOLD (ZT_NETWORK_AUTOCONF_DELAY * 2) +// Timeout for disk read cache (ms) +#define ZT_NETCONF_DB_CACHE_TTL 5000 + namespace ZeroTier { static json _renderRule(ZT_VirtualNetworkRule &rule) @@ -1244,8 +1247,8 @@ void EmbeddedNetworkController::_request( json member; { Mutex::Lock _l(_db_m); - network = _db.get("network",nwids,0); - member = _db.get("network",nwids,"member",identity.address().toString(),0); + network = _db.get("network",nwids,ZT_NETCONF_DB_CACHE_TTL); + member = _db.get("network",nwids,"member",identity.address().toString(),ZT_NETCONF_DB_CACHE_TTL); } if (!network.size()) {