##// END OF EJS Templates
added super simple cache_key paster function for showing and cleaning cache keys
marcink -
r3616:e9ac7544 beta
parent child Browse files
Show More
@@ -0,0 +1,85 b''
1 # -*- coding: utf-8 -*-
2 """
3 rhodecode.lib.paster_commands.cache_keys
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 cleanup-keys paster command for RhodeCode
7
8
9 :created_on: mar 27, 2013
10 :author: marcink
11 :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com>
12 :license: GPLv3, see COPYING for more details.
13 """
14 # This program is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 from __future__ import with_statement
27
28 import os
29 import sys
30 import logging
31
32 from os.path import dirname as dn, join as jn
33 from rhodecode.model.meta import Session
34 #to get the rhodecode import
35 rc_path = dn(dn(dn(os.path.realpath(__file__))))
36 sys.path.append(rc_path)
37 from rhodecode.lib.utils import BasePasterCommand
38
39 from rhodecode.model.db import CacheInvalidation
40
41
42 log = logging.getLogger(__name__)
43
44
45 class Command(BasePasterCommand):
46
47 max_args = 1
48 min_args = 1
49
50 usage = "CONFIG_FILE"
51 group_name = "RhodeCode"
52 takes_config_file = -1
53 parser = BasePasterCommand.standard_parser(verbose=True)
54 summary = "Cache keys utils"
55
56 def command(self):
57 #get SqlAlchemy session
58 self._init_session()
59 _caches = CacheInvalidation.query().order_by(CacheInvalidation.cache_key).all()
60 if self.options.show:
61 for c_obj in _caches:
62 print 'key:%s active:%s' % (c_obj.cache_key, c_obj.cache_active)
63 elif self.options.cleanup:
64 for c_obj in _caches:
65 Session().delete(c_obj)
66 print 'removing key:%s' % (c_obj.cache_key)
67 Session().commit()
68 else:
69 print 'nothing done exiting...'
70 sys.exit(0)
71
72 def update_parser(self):
73 self.parser.add_option(
74 '--show',
75 action='store_true',
76 dest='show',
77 help=("show existing cache keys with together with status")
78 )
79
80 self.parser.add_option(
81 '--cleanup',
82 action="store_true",
83 dest="cleanup",
84 help="cleanup existing cache keys"
85 )
@@ -164,6 +164,7 b' setup('
164 update-repoinfo=rhodecode.lib.paster_commands.update_repoinfo:Command
164 update-repoinfo=rhodecode.lib.paster_commands.update_repoinfo:Command
165 make-rcext=rhodecode.lib.paster_commands.make_rcextensions:Command
165 make-rcext=rhodecode.lib.paster_commands.make_rcextensions:Command
166 repo-scan=rhodecode.lib.paster_commands.repo_scan:Command
166 repo-scan=rhodecode.lib.paster_commands.repo_scan:Command
167 cache-keys=rhodecode.lib.paster_commands.cache_keys:Command
167 make-index=rhodecode.lib.indexers:MakeIndex
168 make-index=rhodecode.lib.indexers:MakeIndex
168 upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb
169 upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb
169 celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand
170 celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand
General Comments 0
You need to be logged in to leave comments. Login now