view silorider/cache/memory.py @ 41:1db1890edcf5

Change populate command's 'until' argument to be exclusive and support time The argument can now specify a time within the day, but this forces the argument to now be exclusive. So if only a date is provided (no time), you need to enter the next day, i.e. the first day to *not* be included. This makes the argument effectively exclusive.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 20 Aug 2023 11:14:31 -0700
parents a1b7a459326a
children
line wrap: on
line source

from .base import Cache


class MemoryCache(Cache):
    def __init__(self):
        self._vals = {}
        self._posted = {}

    def getCustomValue(self, name, valtype=str):
        return self._vals.get(name)

    def setCustomValue(self, name, val):
        self._vals[name] = val

    def wasPosted(self, silo_name, entry_uri):
        uris = self._posted.get(silo_name)
        if uris:
            return entry_uri in uris
        return False

    def addPost(self, silo_name, entry_uri):
        uris = self._posted.setdefault(silo_name, set())
        uris.add(entry_uri)