This repository was archived by the owner on Sep 12, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +30
-8
lines changed Expand file tree Collapse file tree 1 file changed +30
-8
lines changed Original file line number Diff line number Diff line change 10
10
11
11
# Default options
12
12
13
- redis_opts = {
14
- 'host' : 'localhost' ,
15
- 'port' : 6379 ,
16
- 'db' : 0 ,
17
- 'password' : None
18
- }
19
13
redis_conn = None
20
14
cache_prefix = None
21
15
22
16
23
17
def init ():
24
- global redis_conn , cache_prefix
25
18
cfg = config .load ()
19
+ enable_redis_cache (cfg )
20
+ enable_redis_lru (cfg )
21
+
22
+
23
+ def enable_redis_cache (cfg ):
24
+ global redis_conn , cache_prefix
26
25
cache = cfg .cache
27
26
if not cache :
28
27
return
29
28
30
29
logging .info ('Enabling storage cache on Redis' )
31
30
if not isinstance (cache , dict ):
32
31
cache = {}
32
+ redis_opts = {
33
+ 'host' : 'localhost' ,
34
+ 'port' : 6379 ,
35
+ 'db' : 0 ,
36
+ 'password' : None
37
+ }
33
38
for k , v in cache .iteritems ():
34
39
redis_opts [k ] = v
35
40
logging .info ('Redis config: {0}' .format (redis_opts ))
@@ -39,7 +44,24 @@ def init():
39
44
password = redis_opts ['password' ])
40
45
cache_prefix = 'cache_path:{0}' .format (cfg .get ('storage_path' , '/' ))
41
46
42
- # Enable the LRU as well
47
+
48
+ def enable_redis_lru (cfg ):
49
+ cache = cfg .cache_lru
50
+ if not cache :
51
+ return
52
+ logging .info ('Enabling lru cache on Redis' )
53
+ if not isinstance (cache , dict ):
54
+ cache = {}
55
+ redis_opts = {
56
+ 'host' : 'localhost' ,
57
+ 'port' : 6379 ,
58
+ 'db' : 0 ,
59
+ 'password' : None
60
+ }
61
+ for k , v in cache .iteritems ():
62
+ redis_opts [k ] = v
63
+
64
+ logging .info ('Redis lru config: {0}' .format (redis_opts ))
43
65
lru .init (
44
66
host = redis_opts ['host' ],
45
67
port = int (redis_opts ['port' ]),
You can’t perform that action at this time.
0 commit comments