Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit 49c3f3d

Browse files
author
Mangled Deutz
committed
Tentative fix for lru cache config
Docker-DCO-1.1-Signed-off-by: Mangled Deutz <[email protected]> (github: dmp42)
1 parent 5bad884 commit 49c3f3d

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

docker_registry/lib/cache.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@
1010

1111
# Default options
1212

13-
redis_opts = {
14-
'host': 'localhost',
15-
'port': 6379,
16-
'db': 0,
17-
'password': None
18-
}
1913
redis_conn = None
2014
cache_prefix = None
2115

2216

2317
def init():
24-
global redis_conn, cache_prefix
2518
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
2625
cache = cfg.cache
2726
if not cache:
2827
return
2928

3029
logging.info('Enabling storage cache on Redis')
3130
if not isinstance(cache, dict):
3231
cache = {}
32+
redis_opts = {
33+
'host': 'localhost',
34+
'port': 6379,
35+
'db': 0,
36+
'password': None
37+
}
3338
for k, v in cache.iteritems():
3439
redis_opts[k] = v
3540
logging.info('Redis config: {0}'.format(redis_opts))
@@ -39,7 +44,24 @@ def init():
3944
password=redis_opts['password'])
4045
cache_prefix = 'cache_path:{0}'.format(cfg.get('storage_path', '/'))
4146

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))
4365
lru.init(
4466
host=redis_opts['host'],
4567
port=int(redis_opts['port']),

0 commit comments

Comments
 (0)