Skip to content

Invalidation of Foreign Keys #50

Open
@npetrell

Description

@npetrell

Line 244 of base.py specifically finds foreign keys and invalidates those as well.

def _cache_keys(self):
    """Return the cache key for self plus all related foreign keys."""
    fks = dict((f, getattr(self, f.attname)) for f in self._meta.fields
                if isinstance(f, models.ForeignKey))

    keys = [fk.rel.to._cache_key(val, self._state.db) for fk, val in fks.items()
            if val is not None and hasattr(fk.rel.to, '_cache_key')]
    return (self.cache_key,) + tuple(keys)

What is the reasoning behind including foreign keys in the invalidation. In our experience, the foreign keys are rarely if ever updated when the related object is updated and so invalidation of the related object seems unnecessary. I am curious, however, if there is a reason that I am not considering.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions