django-cache-machine

Overwriting Manager in Django using django-cache-machine

梦想与她 提交于 2019-12-10 20:04:45
问题 Since the django-cache-machine override the objects model attribute, the right way to modify the queryset is as follows: class ModelAQuerySet(models.query.QuerySet): def foo(self): return self.filter(name='foo') class ModelAManager(base.CachingManager): def __init__(self): super(ModelAManager, self).__init__() def get_query_set(self): return ModelAQuerySet(self.model, using=self._db) def foo(self): return self.get_query_set().foo() class ModelA(base.CachingMixin, models.Model): #fields ...

Determine if an attribute is a `DeferredAttribute` in django

南楼画角 提交于 2019-12-08 14:41:56
问题 The Context I have located a rather critical bug in Django Cache Machine that causes it's invalidation logic to lose its mind after a upgrading from Django 1.4 to 1.7. The bug is localized to invocations of only() on models that extend cache machine's CachingMixin . It results in deep recursions that occasionally bust the stack, but otherwise create huge flush_lists that cache machine uses for bi-directional invalidation for models in ForeignKey relationships. class MyModel(CachingMixin): id

Why is Django returning stale cache data?

陌路散爱 提交于 2019-12-01 16:52:17
I have two Django models as shown below, MyModel1 & MyModel2 : class MyModel1(CachingMixin, MPTTModel): name = models.CharField(null=False, blank=False, max_length=255) objects = CachingManager() def __str__(self): return "; ".join(["ID: %s" % self.pk, "name: %s" % self.name, ] ) class MyModel2(CachingMixin, models.Model): name = models.CharField(null=False, blank=False, max_length=255) model1 = models.ManyToManyField(MyModel1, related_name="MyModel2_MyModel1") objects = CachingManager() def __str__(self): return "; ".join(["ID: %s" % self.pk, "name: %s" % self.name, ] ) MyModel2 has a

Why is Django returning stale cache data?

爱⌒轻易说出口 提交于 2019-12-01 15:00:49
问题 I have two Django models as shown below, MyModel1 & MyModel2 : class MyModel1(CachingMixin, MPTTModel): name = models.CharField(null=False, blank=False, max_length=255) objects = CachingManager() def __str__(self): return "; ".join(["ID: %s" % self.pk, "name: %s" % self.name, ] ) class MyModel2(CachingMixin, models.Model): name = models.CharField(null=False, blank=False, max_length=255) model1 = models.ManyToManyField(MyModel1, related_name="MyModel2_MyModel1") objects = CachingManager() def