pydanny/cached-property

Add timed cached_property

pydanny opened this issue · 0 comments

Must work like this:

class Monopoly(object):

    def __init__(self):
        self.boardwalk_price = 500
        self.parkplace_price = 450

    # No time specified so cache is indefinite
    @timed_cached_property
    def boardwalk(self):
        self.boardwalk_price += 50
        return self.boardwalk_price

    # Time of 300 specified, making cache last for 5 minutes before invalidation
    @timed_cached_property(ttl=300)
    def parkplace(self):
        self.timed_cached_property += 50
        return self.timed_cached_property

Notes: