def __setitem__(self, key, value):
        '''
        add a new item or update an old one
        '''
        try:
            self._lock.acquire()
            self.prune()    # here we make a choice - if we prune a the beginning, we may wind up with size+1
                            # items; if we prune at the end, we might keep an expired item. Not serious.

            item = self._data.get(key)
            if item:
                item.value = value
            else:
                item = self._data[key] = _Item(key, value)

            self._setNewest(item)

        finally:
            self._lock.release()

        add a new item or update an old one
        
recipes/Python/498266_selfcleaning_dictlike_container_which_limits/recipe-498266.py