Show More
@@ -1,45 +1,46 b'' | |||||
1 | # RhodeCode VCSServer provides access to different vcs backends via network. |
|
1 | # RhodeCode VCSServer provides access to different vcs backends via network. | |
2 | # Copyright (C) 2014-2020 RhodeCode GmbH |
|
2 | # Copyright (C) 2014-2020 RhodeCode GmbH | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or modify |
|
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by |
|
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 3 of the License, or |
|
6 | # the Free Software Foundation; either version 3 of the License, or | |
7 | # (at your option) any later version. |
|
7 | # (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software Foundation, |
|
15 | # along with this program; if not, write to the Free Software Foundation, | |
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 |
|
17 | |||
18 | from vcsserver.lib import rc_cache |
|
18 | from vcsserver.lib import rc_cache | |
19 |
|
19 | |||
20 | class RemoteBase(object): |
|
20 | class RemoteBase(object): | |
21 | EMPTY_COMMIT = '0' * 40 |
|
21 | EMPTY_COMMIT = '0' * 40 | |
22 |
|
22 | |||
23 | def _region(self, wire): |
|
23 | def _region(self, wire): | |
24 | repo_id = wire.get('repo_id', '') |
|
24 | cache_repo_id = wire.get('cache_repo_id', '') | |
25 | cache_namespace_uid = 'cache_repo.{}'.format(repo_id) |
|
25 | cache_namespace_uid = 'cache_repo.{}'.format(cache_repo_id) | |
26 | return rc_cache.get_or_create_region('repo_object', cache_namespace_uid) |
|
26 | return rc_cache.get_or_create_region('repo_object', cache_namespace_uid) | |
27 |
|
27 | |||
28 | def _cache_on(self, wire): |
|
28 | def _cache_on(self, wire): | |
29 | context = wire.get('context', '') |
|
29 | context = wire.get('context', '') | |
30 | context_uid = '{}'.format(context) |
|
30 | context_uid = '{}'.format(context) | |
31 | repo_id = wire.get('repo_id', '') |
|
31 | repo_id = wire.get('repo_id', '') | |
32 | cache = wire.get('cache', True) |
|
32 | cache = wire.get('cache', True) | |
33 | cache_on = context and cache |
|
33 | cache_on = context and cache | |
34 | return cache_on, context_uid, repo_id |
|
34 | return cache_on, context_uid, repo_id | |
35 |
|
35 | |||
36 | def vcsserver_invalidate_cache(self, wire, delete): |
|
36 | def vcsserver_invalidate_cache(self, wire, delete): | |
37 | from vcsserver.lib import rc_cache |
|
37 | from vcsserver.lib import rc_cache | |
38 | repo_id = wire.get('repo_id', '') |
|
38 | repo_id = wire.get('repo_id', '') | |
|
39 | cache_repo_id = wire.get('cache_repo_id', '') | |||
|
40 | cache_namespace_uid = 'cache_repo.{}'.format(cache_repo_id) | |||
39 |
|
41 | |||
40 | if delete: |
|
42 | if delete: | |
41 | cache_namespace_uid = 'cache_repo.{}'.format(repo_id) |
|
|||
42 | rc_cache.clear_cache_namespace( |
|
43 | rc_cache.clear_cache_namespace( | |
43 | 'repo_object', cache_namespace_uid, invalidate=True) |
|
44 | 'repo_object', cache_namespace_uid, invalidate=True) | |
44 |
|
45 | |||
45 | return {'invalidated': {'repo_id': repo_id, 'delete': delete}} |
|
46 | return {'invalidated': {'repo_id': repo_id, 'delete': delete}} |
General Comments 0
You need to be logged in to leave comments.
Login now