Add utility command to forget parts of the cache.
2 files changed, 42 insertions(+), 0 deletions(-)

M silorider/commands/utils.py
M silorider/main.py
M silorider/commands/utils.py +16 -0
@@ 87,3 87,19 @@ def _populate_cache_for_url(name, url, c
                 ctx.cache.addPost(silo.name, entry_url)
             else:
                 logger.debug("Would add entry to '%s' cache: %s" % (silo.name, entry_url))
+
+
+def forget_cache(ctx):
+    named_urls = get_named_urls(ctx.config, ctx.args.url)
+
+    since_dt = None
+    until_dt = None
+    if ctx.args.since:
+        since_dt = dateutil.parser.parse(ctx.args.since)
+        logger.debug("Forgetting cached entries since: %s" % since_dt)
+        since_dt = since_dt.timestamp()
+    if ctx.args.until:
+        until_dt = dateutil.parser.parse(ctx.args.until)
+        logger.debug("Forgetting cached entries until: %s" % until_dt)
+        until_dt = until_dt.timestamp()
+

          
M silorider/main.py +26 -0
@@ 93,6 93,28 @@ def _setup_populate(parser):
     parser.set_defaults(func=_run)
 
 
+def _setup_forget(parser):
+    def _run(ctx):
+        from .commands.utils import forget_cache
+        forget_cache(ctx)
+
+    parser.add_argument(
+        '-s', '--silo',
+        action='append',
+        help="Only froget entries from the given silo(s).")
+    parser.add_argument(
+        '--since',
+        help="The date after which to forget entries from the cache (excluded).")
+    parser.add_argument(
+        '--until',
+        help="The date until which to forget entries from the cache (excluded).")
+    parser.add_argument(
+        '--dry-run',
+        action='store_true',
+        help="Only report what would be forgotten, but don't forget anything.")
+    parser.set_defaults(func=_run)
+
+
 commands = {
     'auth': {
         'help': "Authenticate with a silo service.",

          
@@ 105,6 127,10 @@ commands = {
     'populate': {
         'help': "Populates the cache with the latest entries from a feed.",
         'setup': _setup_populate,
+    },
+    'forget': {
+        'help': "Forget entries from the cache, so they can be reposted.",
+        'setup': _setup_forget,
     }
 }