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 +15
-5
lines changed
depends/docker-registry-core/docker_registry/core Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,11 @@ def wrapper(*args):
6666 key = args [- 2 ]
6767 key = cache_key (key )
6868 try :
69+ cached_content = get_by_key (key )
70+ if cached_content and cached_content == content :
71+ # If cached content is the same as what we are about to
72+ # write, we don't need to write again.
73+ return args [- 2 ]
6974 redis_conn .set (key , content )
7075 except redis .exceptions .ConnectionError as e :
7176 logging .warning ("LRU: Redis connection error: {0}" .format (e ))
@@ -81,11 +86,7 @@ def get(f):
8186 def wrapper (* args ):
8287 key = args [- 1 ]
8388 key = cache_key (key )
84- try :
85- content = redis_conn .get (key )
86- except redis .exceptions .ConnectionError as e :
87- logging .warning ("LRU: Redis connection error: {0}" .format (e ))
88- content = None
89+ content = get_by_key (key )
8990
9091 if content is not None :
9192 return content
@@ -102,6 +103,15 @@ def wrapper(*args):
102103 return wrapper
103104
104105
106+ def get_by_key (key ):
107+ try :
108+ content = redis_conn .get (key )
109+ except redis .exceptions .ConnectionError as e :
110+ logging .warning ("LRU: Redis connection error: {0}" .format (e ))
111+ return None
112+ return content
113+
114+
105115def remove (f ):
106116 @functools .wraps (f )
107117 def wrapper (* args ):
You can’t perform that action at this time.
0 commit comments