add a couple of cache management commands
Change-Id: I15c14f9a64a9ae5d8dca6dd452d6ebae18fb51be Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
a479f92888
commit
6e76c3a5a0
@ -39,3 +39,8 @@ class Cache:
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._shelf[self._mk_key(key)]
|
||||
|
||||
def __delitem__(self, key):
|
||||
real_key = self._mk_key(key)
|
||||
if real_key in self._shelf:
|
||||
del self._shelf[real_key]
|
||||
|
61
goal_tools/who_helped/cache.py
Normal file
61
goal_tools/who_helped/cache.py
Normal file
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import pprint
|
||||
|
||||
from cliff import command
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CacheRemove(command.Command):
|
||||
"Remove an entry from the cache."
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'type',
|
||||
choices=['review', 'email'],
|
||||
help='the kind of thing to remove',
|
||||
)
|
||||
parser.add_argument(
|
||||
'id',
|
||||
help='the id of the item to remove',
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
del self.app.cache[(parsed_args.type, parsed_args.id)]
|
||||
|
||||
|
||||
class CacheShow(command.Command):
|
||||
"Show an entry in the cache."
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'type',
|
||||
choices=['review', 'email'],
|
||||
help='the kind of thing to remove',
|
||||
)
|
||||
parser.add_argument(
|
||||
'id',
|
||||
help='the id of the item to remove',
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
data = self.app.cache[(parsed_args.type, parsed_args.id)]
|
||||
pprint.pprint(data)
|
@ -32,6 +32,8 @@ who_helped =
|
||||
contributions list = goal_tools.who_helped.contributions:ListContributions
|
||||
member show = goal_tools.who_helped.members:ShowMember
|
||||
changes query = goal_tools.who_helped.changes:QueryChanges
|
||||
cache remove = goal_tools.who_helped.cache:CacheRemove
|
||||
cache show = goal_tools.who_helped.cache:CacheShow
|
||||
|
||||
|
||||
[wheel]
|
||||
|
Loading…
Reference in New Issue
Block a user