##// END OF EJS Templates
Optimize cache key building
neko259 -
r2013:240e0e67 default
parent child Browse files
Show More
@@ -19,8 +19,6 b' from neboard import settings'
19 from boards.abstracts.constants import FILE_DIRECTORY
19 from boards.abstracts.constants import FILE_DIRECTORY
20 from boards.settings import get_bool, SECTION_FORMS
20 from boards.settings import get_bool, SECTION_FORMS
21
21
22 CACHE_KEY_DELIMITER = '_'
23
24 HTTP_FORWARDED = 'HTTP_X_FORWARDED_FOR'
22 HTTP_FORWARDED = 'HTTP_X_FORWARDED_FOR'
25 META_REMOTE_ADDR = 'REMOTE_ADDR'
23 META_REMOTE_ADDR = 'REMOTE_ADDR'
26
24
@@ -31,7 +29,9 b" ANON_IP = '127.0.0.1'"
31
29
32 FILE_EXTENSION_DELIMITER = '.'
30 FILE_EXTENSION_DELIMITER = '.'
33 URL_DELIMITER = '/'
31 URL_DELIMITER = '/'
34 CACHE_KEY_DELIMITER = ':'
32
33 CACHE_PARAMS = '{}:{}'
34 CACHE_KEY_DELIMITER = '_'
35
35
36 DEFAULT_MIMETYPE = 'application/octet-stream'
36 DEFAULT_MIMETYPE = 'application/octet-stream'
37
37
@@ -71,7 +71,7 b' def cached_result(key_method=None):'
71
71
72 cache_key_params += args
72 cache_key_params += args
73 for key, value in kwargs:
73 for key, value in kwargs:
74 cache_key_params.append(key + CACHE_KEY_DELIMITER + value)
74 cache_key_params.append(CACHE_PARAMS.format(key, value))
75
75
76 if isinstance(obj, Model):
76 if isinstance(obj, Model):
77 cache_key_params.append(str(obj.id))
77 cache_key_params.append(str(obj.id))
General Comments 0
You need to be logged in to leave comments. Login now