'Invalidate some fields for some records in the cache of all
environments.
:param spec: what to invalidate, a list of `(field, ids)` pair,
where ``field`` is a field object, and ``ids`` is a list of record
ids or ``None`` (to invalidate all records).'

def invalidate(self, spec):

    if (not spec):
        return
    for env in list(self.all):
        c = env.cache
        for (field, ids) in spec:
            if (ids is None):
                if (field in c):
                    del c[field]
            else:
                field_cache = c[field]
                for id in ids:
                    field_cache.pop(id, None)
