Skip to content

Invalidation of Foreign Keys #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
npetrell opened this issue Dec 2, 2013 · 2 comments
Open

Invalidation of Foreign Keys #50

npetrell opened this issue Dec 2, 2013 · 2 comments

Comments

@npetrell
Copy link

npetrell commented Dec 2, 2013

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.

@npetrell
Copy link
Author

npetrell commented Dec 3, 2013

@jbalogh. Not sure if anyone saw this or not. Just curious if there are any thoughts on this issue.

@andreacimino
Copy link

I would like to have an explanation too,
my suspicion is that that this invalidation is need when explicit joins are needed.
Since I use a non relational database, I would like to know if this operation is needed or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants