diff --git a/lib/core/decorators.py b/lib/core/decorators.py index 1f5cd0979..de23c66d6 100644 --- a/lib/core/decorators.py +++ b/lib/core/decorators.py @@ -14,10 +14,11 @@ from lib.core.settings import MAX_CACHE_ITEMS from lib.core.settings import UNICODE_ENCODING from lib.core.threads import getCurrentThreadData +_cache = {} _cache_lock = threading.Lock() _method_locks = {} -def cachedmethod(f, cache=LRUDict(capacity=MAX_CACHE_ITEMS)): +def cachedmethod(f): """ Method with a cached content @@ -34,22 +35,24 @@ def cachedmethod(f, cache=LRUDict(capacity=MAX_CACHE_ITEMS)): Reference: http://code.activestate.com/recipes/325205-cache-decorator-in-python-24/ """ + _cache[f] = LRUDict(capacity=MAX_CACHE_ITEMS) + @functools.wraps(f) - def _(*args, **kwargs): + def _f(*args, **kwargs): key = int(hashlib.md5("|".join(str(_) for _ in (f, args, kwargs)).encode(UNICODE_ENCODING)).hexdigest(), 16) & 0x7fffffffffffffff try: with _cache_lock: - result = cache[key] + result = _cache[f][key] except KeyError: result = f(*args, **kwargs) with _cache_lock: - cache[key] = result + _cache[f][key] = result return result - return _ + return _f def stackedmethod(f): """ diff --git a/lib/core/settings.py b/lib/core/settings.py index abf8694a8..3df9c7cf8 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.3.7.40" +VERSION = "1.3.7.41" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)