[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit 68b912436444ba93e2b4c7db2644555fb3ddfe48
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
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:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits