def METHOD_NAME(self, key, value):
    cached = key in self.cache or key in self.weakrefs
    self.cache[key] = value
    self.weakrefs[key] = value
    self._ref_key(key)
    if not cached:
        self._purge()