mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-08-27 04:05:58 +00:00
Important patch for #3459
This commit is contained in:
parent
e8f505b701
commit
ed26dc0235
5 changed files with 60 additions and 11 deletions
|
|
@ -7,10 +7,15 @@ See the file 'LICENSE' for copying permission
|
|||
|
||||
import functools
|
||||
import hashlib
|
||||
import threading
|
||||
|
||||
from lib.core.settings import MAX_CACHE_ITEMS
|
||||
from lib.core.datatype import LRUDict
|
||||
from lib.core.threads import getCurrentThreadData
|
||||
|
||||
def cachedmethod(f, cache={}):
|
||||
_lock = threading.Lock()
|
||||
|
||||
def cachedmethod(f, cache=LRUDict(capacity=MAX_CACHE_ITEMS)):
|
||||
"""
|
||||
Method with a cached content
|
||||
|
||||
|
|
@ -19,11 +24,12 @@ def cachedmethod(f, cache={}):
|
|||
|
||||
@functools.wraps(f)
|
||||
def _(*args, **kwargs):
|
||||
key = int(hashlib.md5("|".join(str(_) for _ in (f, args, kwargs))).hexdigest(), 16) & 0x7fffffffffffffff
|
||||
if key not in cache:
|
||||
cache[key] = f(*args, **kwargs)
|
||||
with _lock:
|
||||
key = int(hashlib.md5("|".join(str(_) for _ in (f, args, kwargs))).hexdigest(), 16) & 0x7fffffffffffffff
|
||||
if key not in cache:
|
||||
cache[key] = f(*args, **kwargs)
|
||||
|
||||
return cache[key]
|
||||
return cache[key]
|
||||
|
||||
return _
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue