When I use cache framework api to cache a model instance, @cached_property of the instance doesn't work. Why?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5b27fa47-c712-460f-a421-1eb1d41c764e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
class Log(models.Model):
type = models.CharField(max_length=200, unique=True)
column = SortedManyToManyField(Column, blank=True)
min_column_cnt = models.IntegerField(blank=True, default=0, help_text='0 equal NULL')
@cached_property
def column_list_name(self):
return [col.name for col in self.column.all()]
@cached_property
def column_len(self):
return len(self.column.all())
@cached_property
def get_all_column_checker(self):
column_ids = [c.id for c in self.column.all()]
return ColumnChecker.objects.select_related('column').filter(column_id__in=column_ids)
def get_log_attr(log_type):
global log_attr_dict, log_attr_last_update_ts
if (datetime.now() - log_attr_last_update_ts).total_seconds() < update_log_attr_interval and \
log_type in log_attr_dict:
return log_attr_dict[log_type]
log_attr_dict[log_type] = Log.objects.prefetch_related('column').get(type=log_type)
log_attr_last_update_ts = datetime.now()
return log_attr_dict[log_type]
def get_log_attr(log_type):
log_attr = cache.get(log_type)
if not log_attr:
log_attr = Log.objects.prefetch_related('column').get(type=log_type)
cache.set(log_type, log_attr, update_log_attr_interval)
return log_attr
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMv51WQMrueCfWoBV3a0Djr7QhL3mqXcg_Ak5yNt75%3DP2Vy4WA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGdZMg8v2mp%3DOiO3coBFypGZ5O%2B_FLC_5cfnK94CRXax0OHRYw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMv51WTfACztXVaoCv6GgdJBEBh8KKhdfZXHQRYw4d%2BBC_2rOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGdZMg83qVXpLSCPSkDvvJt%3DmEc%2BRLdjRTxyXdwNjdv4Fy%3DpMg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMv51WTxDj8du2RKgWo%3DD1o5a0O5k1C5E2V1xHPDooc%3DUv662Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.