'Add a mailbox to the cache, potentially evicting other entries if the
cache has grown too large.'

def cache_mailbox(self, session, pfn, mbx_id, mbox):

    with self._lock:
        if (pfn is not None):
            self._mbox_cache = [c for c in self._mbox_cache if (c[0] != pfn)]
        elif mbx_id:
            self._mbox_cache = [c for c in self._mbox_cache if (c[1] != mbx_id)]
        self._mbox_cache.append((pfn, mbx_id, mbox))
        flush = self._mbox_cache[:(- MAX_CACHED_MBOXES)]
    for entry in flush:
        (pfn, mbx_id) = entry[:2]
        self.save_worker.add_unique_task(session, ('Save    mailbox    %s/%s    (drop=%s)' % (mbx_id, pfn, False)), (lambda : self.uncache_mailbox(session, entry, drop=False)))
