summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Cache.py
blob: 842098eda48fc019771707a4283f3bd1c7c36bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
""" An implementation of a simple memory-backed cache. Right now this
doesn't provide many features, but more (time-based expiration, etc.)
can be added as necessary. """


class Cache(dict):
    """ an implementation of a simple memory-backed cache """

    def expire(self, key=None):
        """ expire all items, or a specific item, from the cache """
        if key is None:
            self.clear()
        elif key in self:
            del self[key]