mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-16 12:06:55 +02:00
Use cache on requests to decrease DB load.
This commit is contained in:
parent
d09d193715
commit
37629aaf87
1 changed files with 5 additions and 2 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue