# HG changeset patch # User Martin Bornhold # Date 2016-07-08 14:01:35 # Node ID e1d0ae4c62ece85dcb1fc0074a20db3b2fbb45e6 # Parent 25d338b623c27d33932757a5051df1a6dad7badc http-protocol: Add a method to invalidate the VCSServer cache. This method allows to invalidate the cached repository objects in the VCSServer. It generates a new UUID which is used by the VCSServer as cache key. diff --git a/rhodecode/lib/vcs/client_http.py b/rhodecode/lib/vcs/client_http.py --- a/rhodecode/lib/vcs/client_http.py +++ b/rhodecode/lib/vcs/client_http.py @@ -90,7 +90,7 @@ class RemoteRepo(object): self._wire = { "path": path, "config": config, - "context": str(uuid.uuid4()), + "context": self._create_vcs_cache_context(), } if with_wire: self._wire.update(with_wire) @@ -125,6 +125,21 @@ class RemoteRepo(object): def __getitem__(self, key): return self.revision(key) + def _create_vcs_cache_context(self): + """ + Creates a unique string which is passed to the VCSServer on every + remote call. It is used as cache key in the VCSServer. + """ + return str(uuid.uuid4()) + + def invalidate_vcs_cache(self): + """ + This invalidates the context which is sent to the VCSServer on every + call to a remote method. It forces the VCSServer to create a fresh + repository instance on the next call to a remote method. + """ + self._wire['context'] = self._create_vcs_cache_context() + class RemoteObject(object):