[tor-commits] [stem/master] Expand caching of GETINFO results

atagar at torproject.org atagar at torproject.org
Mon Feb 1 04:21:04 UTC 2016


commit 68b912436444ba93e2b4c7db2644555fb3ddfe48
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Jan 30 18:40:15 2016 -0800

    Expand caching of GETINFO results
    
    Caching several GETINFO queries that can only be changed with a SETCONF. These
    are queries nyx cares about, but we can expand the list as others crop up.
---
 stem/control.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/stem/control.py b/stem/control.py
index 96597e8..8c30b28 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -347,6 +347,15 @@ CACHEABLE_GETINFO_PARAMS = (
   'events/names',
   'features/names',
   'process/descriptor-limit',
+  'status/version/current',
+)
+
+CACHEABLE_GETINFO_PARAMS_UNTIL_SETCONF = (
+  'accounting/enabled',
+  'net/listeners/control',
+  'net/listeners/dir',
+  'net/listeners/or',
+  'net/listeners/socks',
 )
 
 # GETCONF parameters we shouldn't cache. This includes hidden service
@@ -1120,7 +1129,7 @@ class Controller(BaseController):
         for key, value in response.entries.items():
           key = key.lower()  # make case insensitive
 
-          if key in CACHEABLE_GETINFO_PARAMS:
+          if key in CACHEABLE_GETINFO_PARAMS or key in CACHEABLE_GETINFO_PARAMS_UNTIL_SETCONF:
             to_cache[key] = value
           elif key.startswith('ip-to-country/'):
             # both cache-able and means that we should reset the geoip failure count
@@ -2331,6 +2340,10 @@ class Controller(BaseController):
           if param == 'exitpolicy':
             self._set_cache({'exitpolicy': None})
 
+        # reset any getinfo parameters that can be changed by a SETCONF
+
+        self._set_cache(dict([(k.lower(), None) for k in CACHEABLE_GETINFO_PARAMS_UNTIL_SETCONF]), 'getinfo')
+
         self._set_cache(to_cache, 'getconf')
         self._set_cache({'get_custom_options': None})
     else:





More information about the tor-commits mailing list