Giter Club home page Giter Club logo

django-cache-toolbox's Issues

Model.get_cached() cache is not invalidated on ForeignKey update from on_delete

Let's say I have a Person object with a ForeignKey to a default image.

class Person(models.Model):
    default_image = models.ForeignKey('people.Image', blank=True, null=True,
         on_delete=models.SET_NULL)

class Image(models.Model):
    some_image_field = models.ImageField(...)

>>> p = Person.objects.get(first_name='Phil')
>>> img = Image.objects.get(**some_kwargs)
>>> p_cached = Person.get_cached(pk=p.pk)
>>> p.default_image = img
>>> p.save()
>>> p_cached = Person.get_cached(pk=p.pk)
>>> p.default_image is not None
True
>>> p_cached.default_image is not None
True
>>> img.delete()
>>> p.default_image is None
True
>>> p_cached = Person.get_cached(pk=p.pk)
>>> p_cached.default_image is None
Traceback (most recent call last)
...
File "django/db/models/fields/related.py", line 316, in __get__
rel_obj = QuerySet(self.field.rel.to).using(db).get(**params)
DoesNotExist: Image matching query does not exist.

It's a pretty tricky bug, and it may be nearly impossible to fix if the on_delete actually sets a database property that leads to that behavior rather than doing it in Python.

Nonetheless, I felt I should probably report it just so it's a known issue.

No Support for ForeignKey Caches

Hi there!

Great work on this project. It looks like the commits have been coming fast recently, and I realize you say support for ForeignKey fields is planned, but I just wanted to put a ticket in to ping you about that.

ForeignKey support would be a great feature and would significantly decrease db hits for me.

The scaling isn't that important for me yet, so I probably won't be able to commit any time to helping out with this feature in the immediate future, but once we go live if this is a bottleneck I'd certainly be happy to work on this.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.