|
31 | 31 | from itertools import groupby, chain |
32 | 32 | from tempfile import NamedTemporaryFile |
33 | 33 |
|
34 | | -import redis |
| 34 | +import cache |
35 | 35 |
|
36 | 36 | MYDIR = os.path.abspath(os.path.join(__file__, '..', '..')) |
37 | 37 | sys.path.append("%s/lib/" % MYDIR) |
38 | 38 | from languages_data import VIM_NAME |
39 | | -from globals import PATH_VIM_ENVIRONMENT, REDISHOST |
| 39 | +from globals import PATH_VIM_ENVIRONMENT |
40 | 40 | # pylint: enable=wrong-import-position,wrong-import-order |
41 | 41 |
|
42 | | -if os.environ.get('REDIS_HOST', '').lower() != 'none': |
43 | | - REDIS = redis.StrictRedis(host=REDISHOST, port=6379, db=1) |
44 | | -else: |
45 | | - REDIS = None |
46 | | - |
47 | 42 | FNULL = open(os.devnull, 'w') |
48 | 43 | TEXT = 0 |
49 | 44 | CODE = 1 |
@@ -301,16 +296,12 @@ def beautify(text, lang, options): |
301 | 296 | # if mode is unknown, just don't transform the text at all |
302 | 297 | return text |
303 | 298 |
|
304 | | - if REDIS: |
305 | | - digest = "t:%s:%s:%s" % (hashlib.md5(text).hexdigest(), lang, mode) |
306 | | - answer = REDIS.get(digest) |
307 | | - if answer: |
308 | | - return answer |
309 | | - |
| 299 | + digest = "t:%s:%s:%s" % (hashlib.md5(text).hexdigest(), lang, mode) |
| 300 | + answer = cache.get(digest) |
| 301 | + if answer: |
| 302 | + return answer |
310 | 303 | answer = _beautify(text, lang, **beauty_options) |
311 | | - |
312 | | - if REDIS: |
313 | | - REDIS.set(digest, answer) |
| 304 | + cache.put(digest, answer) |
314 | 305 |
|
315 | 306 | return answer |
316 | 307 |
|
|
0 commit comments